com.xebialabs.deployit.mapper
Class Mapper<S extends java.io.Serializable,M extends Mapping,T extends java.io.Serializable>

java.lang.Object
  extended by com.xebialabs.deployit.mapper.Mapper<S,M,T>
Type Parameters:
S - the type of the source artifact/resource.
M - the type of the mapping.
T - the type of the target middleware.
Direct Known Subclasses:
StepGeneratingMapper

public abstract class Mapper<S extends java.io.Serializable,M extends Mapping,T extends java.io.Serializable>
extends java.lang.Object

Calculates which source artifact/resource is mapped to what middleware target.


Field Summary
protected  java.util.List<M> addedMappings
           
protected  Change<Deployment> change
           
protected  java.util.List<M> deletedMappings
           
protected  java.util.List<Pair<M,M>> modifiedMappings
           
protected  java.util.List<M> newMappings
           
protected  java.util.List<M> oldMappings
           
 
Constructor Summary
protected Mapper(Change<Deployment> change)
          Creates a Mapper for the specified deployment change that will apply default mappings.
protected Mapper(Change<Deployment> change, boolean applyDefaultMappings)
          Creates a Mapper for the specified deployment change.
 
Method Summary
 java.util.List<M> getAddedMappings()
          Returns the list of added mappings.
 java.util.Set<T> getAffectedTargets()
          Gets the affected targets of all the mappings.
 java.util.Set<T> getAllTargets()
          Gets all the targets of all the mappings, old and new.
 java.util.List<M> getDeletedMappings()
          Returns the list of deleted mappings.
 java.util.List<Pair<M,M>> getModifiedMappings()
          Returns the list of modified mappings.
 java.util.List<M> getNewMappings()
          Returns the list of new mappings.
 java.util.Set<T> getNewTargets()
          Gets all the targets of the new mappings.
 java.util.List<M> getOldMappings()
          Returns the list of old mappings.
 java.util.Set<T> getOldTargets()
          Gets all the targets of the old mappings.
protected  void init()
           
 void setDefaults(Deployment deployment, M newDefaultMapping)
          Can be overridden by a subclass to set the defaults on a automatically generated default mapping.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

change

protected Change<Deployment> change

oldMappings

protected java.util.List<M extends Mapping> oldMappings

newMappings

protected java.util.List<M extends Mapping> newMappings

addedMappings

protected java.util.List<M extends Mapping> addedMappings

modifiedMappings

protected java.util.List<Pair<M extends Mapping,M extends Mapping>> modifiedMappings

deletedMappings

protected java.util.List<M extends Mapping> deletedMappings
Constructor Detail

Mapper

protected Mapper(Change<Deployment> change,
                 boolean applyDefaultMappings)
Creates a Mapper for the specified deployment change. Uses the approach described in this blog by Arjan Blokzijl to infer the actual type arguments.

Parameters:
change - the deployment change for which to calculcate mappings.
applyDefaultMappings - default mappings will be applied iff true

Mapper

protected Mapper(Change<Deployment> change)
Creates a Mapper for the specified deployment change that will apply default mappings.

Parameters:
change - the deployment change for which to calculcate mappings.
Method Detail

init

protected void init()

getOldMappings

public java.util.List<M> getOldMappings()
Returns the list of old mappings. A mapping is considered to be old if it was part of the old revision of the deployment.

Returns:
a list of the old mappings

getNewMappings

public java.util.List<M> getNewMappings()
Returns the list of new mappings. A mapping is considered to be new if it was part of the new revision of the deployment.

Returns:
a list of the new mappings

getAddedMappings

public java.util.List<M> getAddedMappings()
Returns the list of added mappings. A mapping is considered to be added for one of two reasons:

Returns:
a list of the added mappings

getModifiedMappings

public java.util.List<Pair<M,M>> getModifiedMappings()
Returns the list of modified mappings. A mapping is considered to be modified if the deployment was modified and a similar but not ConfigurationItemReflectionUtils.isIdentical(Serializable, Serializable) mapping existed in the old and the new version.

Returns:
list of modified mappings as pairs; the first element of the pair is the old mapping and the second element of the pair is the new mapping.

getDeletedMappings

public java.util.List<M> getDeletedMappings()
Returns the list of deleted mappings. A mapping is considered to be deleted for one of two reasons:

Returns:
a list of the added mappings

getAllTargets

public java.util.Set<T> getAllTargets()
Gets all the targets of all the mappings, old and new.

Returns:
a set of all targets.

getAffectedTargets

public java.util.Set<T> getAffectedTargets()
Gets the affected targets of all the mappings. The affected targets are targets for which one ore more mappings were added, modified or deleted.

Returns:
a set of the affected targets.

getOldTargets

public java.util.Set<T> getOldTargets()
Gets all the targets of the old mappings.

Returns:
a set of the targets of the old mappings.

getNewTargets

public java.util.Set<T> getNewTargets()
Gets all the targets of the new mappings.

Returns:
a set of the targets of the new mappings.

setDefaults

public void setDefaults(Deployment deployment,
                        M newDefaultMapping)
Can be overridden by a subclass to set the defaults on a automatically generated default mapping. This default implementation does nothing.

Parameters:
deployment - the deployment for which this default mapping was created
newDefaultMapping - the newly created default mapping


Copyright © 2010. All Rights Reserved.