Package ma.glasnost.orika.metadata

Examples of ma.glasnost.orika.metadata.Property


 
  @Test
  public void testOverridePropertyDefinition() {
     
      Map<String, Property> properties = propertyResolver.getProperties(PostalAddress.class);
      Property city = properties.get("city");
     
      Assert.assertNotNull(city.getSetter());
  }
View Full Code Here


     */
    public static class ElementPropertyResolver extends IntrospectorPropertyResolver {
       
        protected Property getProperty(java.lang.reflect.Type type, String expr, boolean isNestedLookup, Property owner)
                throws MappingException {
            Property property = null;
            try {
                property = super.getProperty(type, expr, isNestedLookup, null);
            } catch (MappingException e) {
                try {
                    property = super.resolveInlineProperty(type, expr + ":{getAttribute(\"" + expr + "\")|setAttribute(\"" + expr
View Full Code Here

 
  @Test
  public void testOverridePropertyDefinition() {
     
      Map<String, Property> properties = propertyResolver.getProperties(PostalAddress.class);
      Property city = properties.get("city");
     
      Assert.assertNotNull(city.getSetter());
  }
View Full Code Here

  }
 
  @Test
    public void testAdHocResolution() {
     
      Property prop = propertyResolver.getProperty(A.class, "name:{readTheNameForThisBean|assignTheName}.firstName");
     
      Assert.assertNotNull(prop);
      Assert.assertEquals("firstName", prop.getName());
      Assert.assertEquals("name.firstName", prop.getExpression());
      Assert.assertEquals(TypeFactory.valueOf(String.class), prop.getType());
  }
View Full Code Here

 
 
  @Test
    public void testAdHocResolution_withType() {
       
        Property prop = propertyResolver.getProperty(A.class, "name:{readTheNameForThisBean|assignTheName|type=ma.glasnost.orika.test.property.TestCaseClasses$Name}.firstName");
       
        Assert.assertNotNull(prop);
        Assert.assertEquals("firstName", prop.getName());
        Assert.assertEquals("name.firstName", prop.getExpression());
        Assert.assertEquals(TypeFactory.valueOf(String.class), prop.getType());
    }
View Full Code Here

       
        return out.toString();
    }
   
    private Property innermostElement(final Property p) {
        Property result = p;
        while (result.getElement() != null) {
            result = result.getElement();
        }
        return result;
    }
View Full Code Here

   
    private boolean mapFields(Node currentNode, Node srcNode, StringBuilder out, SourceCodeContext code) {
       
        String srcName = srcNode.parent != null ? srcNode.parent.elementRef.name() : "source";
       
        Property sp = innermostElement(currentNode.value.getSource());
        Property srcProp = new Property.Builder().merge(sp).expression(innermostElement(currentNode.value.getSource()).getExpression()).build();
        VariableRef s = new VariableRef(srcProp, srcName);
       
        Property dp = innermostElement(currentNode.value.getDestination());
        Property dstProp = new Property.Builder().merge(dp).expression(innermostElement(currentNode.value.getDestination()).getExpression()).build();
        String dstName =  "destination";
        if (currentNode.parent != null ) {
            dstName = currentNode.parent.elementRef.name();
        }
       
View Full Code Here

                    ClassMapBuilder<?,?> builder = builders.get(key);
                    if (builder == null) {
                        builder = mapperFactory.classMap(key.getAType(), key.getBType());
                        builders.put(key, builder);
                    }
                    Property sp = innermostElement(currentNode.value.getSource());
                    Property dp = innermostElement(currentNode.value.getDestination());
                    builder.fieldMap(sp.getExpression(), dp.getExpression()).add();
                }
            }
        }
       
       
View Full Code Here

 
  @Test
  public void testResolveMapKeys() {
     
      PropertyResolverStrategy propertyResolver = UtilityResolver.getDefaultPropertyResolverStrategy();
      Property namesFirst = propertyResolver.getProperty(PersonDto.class, "names['first']");
     
      Assert.assertNotNull(namesFirst);
      Assert.assertEquals(TypeFactory.valueOf(String.class), namesFirst.getType());
      Assert.assertNull(namesFirst.getContainer());
     
      VariableRef ref = new VariableRef(namesFirst, "destination");
      Assert.assertEquals("((java.lang.String)((java.util.Map)destination.names).get(\"first\"))", ref.toString());
  }
View Full Code Here

          return defaultMapping;
        }
    }
   
  private FieldMap mapConstructorArgument(FieldMap existing, Type<?> argumentType, boolean byDefault) {
    Property destProp = new Property.Builder()
            .name(existing.getDestination().getName())
            .getter(existing.getDestination().getName())
            .type(argumentType)
            .build();
    FieldMap fieldMap = new FieldMap(existing.getSource(), destProp, null,
View Full Code Here

TOP

Related Classes of ma.glasnost.orika.metadata.Property

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.