ma.glasnost.orika.impl.generator.specification
Class AbstractSpecification

java.lang.Object
  extended by ma.glasnost.orika.impl.generator.specification.AbstractSpecification
All Implemented Interfaces:
Specification
Direct Known Subclasses:
AnyTypeToString, ArrayOrCollectionToArray, ArrayOrCollectionToCollection, ArrayOrCollectionToMap, Convert, CopyByReference, EnumToEnum, MapToMap, MultiOccurrenceElementToObject, ObjectToMultiOccurrenceElement, ObjectToObject, PrimitiveAndObject, StringToEnum, StringToStringConvertible, UnmappableEnum

public abstract class AbstractSpecification
extends Object
implements Specification


Field Summary
protected  MapperFactory mapperFactory
           
 
Constructor Summary
AbstractSpecification()
           
 
Method Summary
abstract  boolean appliesTo(FieldMap fieldMap)
          Tests whether this Specification applies to the specified MappedTypePair
 String generateEqualityTestCode(FieldMap fieldMap, VariableRef source, VariableRef destination, SourceCodeContext code)
          Generates code for a boolean equality test between the two variable types, where are potentially unrelated.
abstract  String generateMappingCode(FieldMap fieldMap, VariableRef source, VariableRef destination, SourceCodeContext code)
          Generates code to map the provided field map
 void setMapperFactory(MapperFactory mapperFactory)
           
static boolean shouldMapNulls(FieldMap fieldMap, SourceCodeContext context)
          Tests whether this fieldMap should map nulls;
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mapperFactory

protected MapperFactory mapperFactory
Constructor Detail

AbstractSpecification

public AbstractSpecification()
Method Detail

setMapperFactory

public void setMapperFactory(MapperFactory mapperFactory)
Specified by:
setMapperFactory in interface Specification

shouldMapNulls

public static boolean shouldMapNulls(FieldMap fieldMap,
                                     SourceCodeContext context)
Tests whether this fieldMap should map nulls;

Parameters:
fieldMap -
context -
Returns:

appliesTo

public abstract boolean appliesTo(FieldMap fieldMap)
Description copied from interface: Specification
Tests whether this Specification applies to the specified MappedTypePair

Specified by:
appliesTo in interface Specification
Returns:
true if this specification applies to the given MappedTypePair

generateEqualityTestCode

public String generateEqualityTestCode(FieldMap fieldMap,
                                       VariableRef source,
                                       VariableRef destination,
                                       SourceCodeContext code)
Description copied from interface: Specification
Generates code for a boolean equality test between the two variable types, where are potentially unrelated.

Specified by:
generateEqualityTestCode in interface Specification
Returns:
the code snippet which represents a true|false statement describing whether the two types should be considered 'equal'

generateMappingCode

public abstract String generateMappingCode(FieldMap fieldMap,
                                           VariableRef source,
                                           VariableRef destination,
                                           SourceCodeContext code)
Description copied from interface: Specification
Generates code to map the provided field map

Specified by:
generateMappingCode in interface Specification
Parameters:
fieldMap - the fieldMap for which source code should be generated
source - a convenience wrapper around the source field which can be used facilitate code generation
destination - a convenience wrapper around the destination field which can be used facilitate code generation
Returns:
the code snippet which represents mapping from the source to destination property


Copyright © 2013 Glasnost. All Rights Reserved.