Package org.dozer.fieldmap

Examples of org.dozer.fieldmap.DozerField


*/
public class GetterSetterPropertyDescriptorTest extends AbstractDozerTest {

  @Test
  public void testGetReadMethod() throws Exception {
    DozerField dozerField = new DozerField("destField", "generic");

    JavaBeanPropertyDescriptor pd = new JavaBeanPropertyDescriptor(Dest.class, dozerField.getName(), dozerField.isIndexed(),
        dozerField.getIndex(), null, null);
    Method method = pd.getReadMethod();

    assertNotNull("method should not be null", method);
    assertEquals("incorrect method found", "getDestField", method.getName());
  }
View Full Code Here


        if (!destinationIsMap && classMap.getFieldMapUsingDest(fieldName, true) != null) {
          continue;
        }

        FieldMap fieldMap = new MapFieldMap(classMap);
        DozerField srcField = new DozerField(MappingUtils.isSupportedMap(srcClass) ? DozerConstants.SELF_KEYWORD : fieldName, null);
        srcField.setKey(fieldName);

        if (StringUtils.isNotEmpty(classMap.getSrcClassMapGetMethod())
            || StringUtils.isNotEmpty(classMap.getSrcClassMapSetMethod())) {
          srcField.setMapGetMethod(classMap.getSrcClassMapGetMethod());
          srcField.setMapSetMethod(classMap.getSrcClassMapSetMethod());
          srcField.setName(DozerConstants.SELF_KEYWORD);
        }

        DozerField destField = new DozerField(MappingUtils.isSupportedMap(destClass) ? DozerConstants.SELF_KEYWORD : fieldName,
            null);
        srcField.setKey(fieldName);

        if (StringUtils.isNotEmpty(classMap.getDestClassMapGetMethod())
            || StringUtils.isNotEmpty(classMap.getDestClassMapSetMethod())) {
          destField.setMapGetMethod(classMap.getDestClassMapGetMethod());
          destField.setMapSetMethod(classMap.getDestClassMapSetMethod());
          destField.setName(DozerConstants.SELF_KEYWORD);
        }

        fieldMap.setSrcField(srcField);
        fieldMap.setDestField(destField);
View Full Code Here

      return MappingUtils.isSupportedCollection(srcClass) && MappingUtils.isSupportedCollection(destClass);
    }

    public boolean apply(ClassMap classMap, Configuration configuration) {
      FieldMap fieldMap = new GenericFieldMap(classMap);
      DozerField selfReference = new DozerField(DozerConstants.SELF_KEYWORD, null);
      fieldMap.setSrcField(selfReference);
      fieldMap.setDestField(selfReference);
      classMap.addFieldMapping(fieldMap);
      return true;
    }
View Full Code Here

* @version $Id$
*/
public class GetterSetterPropertyDescriptorWithGenericSuperClassTest extends AbstractDozerTest {
    @Test
    public void testGetReadMethod() throws Exception {
      DozerField dozerField = new DozerField("nestedList", "generic");

      JavaBeanPropertyDescriptor pd = new JavaBeanPropertyDescriptor(Dest.class, dozerField.getName(), dozerField.isIndexed(),
          dozerField.getIndex(), null, null);
      Class<?> clazz = pd.genericType();

      assertNotNull("clazz should not be null", clazz);
      assertEquals("NestedDest generic type", NestedDest.class, clazz);
    }
View Full Code Here

            }
           
            // if the source is a java.util.Map, and not already mapped as key=>value,
            // map the field as key=>value, not as bean property
            if (isSupportedMap(classMap.getSrcClassToMap()) && fieldMap.getSrcFieldKey() == null) {
              DozerField newSrcField = fieldMap.getSrcFieldCopy();
              newSrcField.setName(DozerConstants.SELF_KEYWORD);
              newSrcField.setKey(fieldMap.getSrcFieldName());
              fieldMap.setSrcField(newSrcField);
            }
            // like above but the reverse:
            // if the destination is a java.util.Map, and not already mapped as key=>value,
            // map the field as key=>value, not as bean property
            if (isSupportedMap(classMap.getDestClassToMap()) && fieldMap.getDestFieldKey() == null) {
              DozerField newDestField = fieldMap.getDestFieldCopy();
              newDestField.setName(DozerConstants.SELF_KEYWORD);
              newDestField.setKey(fieldMap.getDestFieldName());
              fieldMap.setDestField(newDestField);
            }

            if (!(MappingDirection.ONE_WAY.equals(fieldMap.getType()) && !(fieldMap instanceof ExcludeFieldMap))) {
              // make a prime field map
View Full Code Here

  }

  public static void addGenericMapping(ClassMap classMap, Configuration configuration, String srcName, String destName) {
    FieldMap fieldMap = new GenericFieldMap(classMap);

    fieldMap.setSrcField(new DozerField(srcName, null));
    fieldMap.setDestField(new DozerField(destName, null));

    // add CopyByReferences per defect #1728159
    MappingUtils.applyGlobalCopyByReference(configuration, fieldMap, classMap);
    classMap.addFieldMapping(fieldMap);
  }
View Full Code Here

    return findCustomConverter(converterByDestTypeCache, customConverterContainer, srcClass, destClass);
  }

  public static void reverseFields(FieldMap source, FieldMap reversed) {
    DozerField destField = source.getSrcFieldCopy();
    DozerField sourceField = source.getDestFieldCopy();

    reversed.setDestField(destField);
    reversed.setSrcField(sourceField);

    reversed.setCustomConverter(source.getCustomConverter());
View Full Code Here

  }

  private static void addFieldMapping(ClassMap classMap, Configuration configuration, String srcName, String destName) {
    FieldMap fieldMap = new GenericFieldMap(classMap);

    DozerField sourceField = new DozerField(srcName, null);
    DozerField destField = new DozerField(destName, null);

    sourceField.setAccessible(true);
    destField.setAccessible(true);

    fieldMap.setSrcField(sourceField);
    fieldMap.setDestField(destField);

    // add CopyByReferences per defect #1728159
View Full Code Here

TOP

Related Classes of org.dozer.fieldmap.DozerField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.