ma.glasnost.orika.metadata
Class ScoringClassMapBuilder<A,B>

java.lang.Object
  extended by ma.glasnost.orika.metadata.ClassMapBuilder<A,B>
      extended by ma.glasnost.orika.metadata.ScoringClassMapBuilder<A,B>
Type Parameters:
A -
B -
All Implemented Interfaces:
MappedTypePair<A,B>

public class ScoringClassMapBuilder<A,B>
extends ClassMapBuilder<A,B>

ScoringClassMapBuilder is an extension of the basic ClassMapBuilder that attempts to compute a best-fit matching of all properties (at every level of nesting) of one type to another, based on various metrics used to measure a given property match.

Since this builder generates mappings based on scoring matches, it cannot always guess the correct mappings; be sure to test and double-check the mappings generated to assure they match expectations.

Note: levenshtein distance implementation is pulled from code found in Apache Commons Lang org.apache.commons.lang.StringUtils, which is based on the implementation provided by Chas Emerick http://www.merriampark.com/ldjava.htm

Author:
matt.deboer@gmail.com

Nested Class Summary
static class ScoringClassMapBuilder.Factory
           
static class ScoringClassMapBuilder.FieldMatchScore
          FieldMatchScore is used to score the match of a pair of property expressions
static class ScoringClassMapBuilder.PropertyMatchingWeights
          PropertyMatchingWeights is a class used to describe how different matching scenarios should be weighted when computing a match score for a set of properties.
 
Constructor Summary
protected ScoringClassMapBuilder(Type<A> aType, Type<B> bType, MapperFactory mapperFactory, PropertyResolverStrategy propertyResolver, DefaultFieldMapper[] defaults, ScoringClassMapBuilder.PropertyMatchingWeights matchingWeights)
          Constructs a new instance of ScoringClassMapBuilder, using the provided PropertyMatchingWeights to adjust the overall scoring of how properties are matched.
 
Method Summary
 ClassMapBuilder<A,B> byDefault(DefaultFieldMapper... withDefaults)
          Configures this class-map builder to employ the default property mapping behavior to any properties that have not already been mapped or excluded; if any DefaultFieldMapper instances are passed, they will be used (instead of those configured on the builder) to attempt a property name match if a direct match is not found.
protected  Map<String,Property> getPropertyExpressions(Type<?> type)
          Gets all of the property expressions for a given type, including all nested properties.
 
Methods inherited from class ma.glasnost.orika.metadata.ClassMapBuilder
addFieldMap, byDefault, byDefault, constructorA, constructorB, customize, customize, describeClassMap, exclude, field, field, field, field, field, field, field, fieldAToB, fieldBToA, fieldMap, fieldMap, fieldMap, fieldMap, fieldMap, fieldMap, fieldMap, fieldMap, fieldMap, fieldMap, getAType, getBType, getDefaultFieldMappers, getMappedFields, getMappedPropertiesForTypeA, getMappedPropertiesForTypeB, getPropertiesForTypeA, getPropertiesForTypeB, getPropertyResolver, isNestedPropertyExpression, map, map, map, map, mapNulls, mapNullsInReverse, register, resolveProperty, resolvePropertyForA, resolvePropertyForB, toClassMap, toString, use, use
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScoringClassMapBuilder

protected ScoringClassMapBuilder(Type<A> aType,
                                 Type<B> bType,
                                 MapperFactory mapperFactory,
                                 PropertyResolverStrategy propertyResolver,
                                 DefaultFieldMapper[] defaults,
                                 ScoringClassMapBuilder.PropertyMatchingWeights matchingWeights)
Constructs a new instance of ScoringClassMapBuilder, using the provided PropertyMatchingWeights to adjust the overall scoring of how properties are matched.

Parameters:
aType -
bType -
propertyResolver -
defaults -
Method Detail

getPropertyExpressions

protected Map<String,Property> getPropertyExpressions(Type<?> type)
Gets all of the property expressions for a given type, including all nested properties. If the type of a property is not immutable and has any nested properties, it will not be included. (Note that the 'class' property is explicitly excluded.)

Parameters:
type - the type for which to gather properties
Returns:
the map of nested properties keyed by expression name

byDefault

public ClassMapBuilder<A,B> byDefault(DefaultFieldMapper... withDefaults)
Description copied from class: ClassMapBuilder
Configures this class-map builder to employ the default property mapping behavior to any properties that have not already been mapped or excluded; if any DefaultFieldMapper instances are passed, they will be used (instead of those configured on the builder) to attempt a property name match if a direct match is not found.

Overrides:
byDefault in class ClassMapBuilder<A,B>
Parameters:
withDefaults - zero or more DefaultFieldMapper instances to apply during the default mapping; if none are supplied, the configured DefaultFieldMappers for the builder (if any) should be used.
Returns:
this ClassMapBuilder instance


Copyright © 2013 Glasnost. All Rights Reserved.