@Override public NestedProperty copy() { Property[] copyPath = new Property[path.length]; for (int i=0, count = path.length; i < count; ++i) { copyPath[i] = path[i].copy(); } NestedProperty copy = new NestedProperty(this.getExpression(), super.copy(), copyPath); return copy; }
public Property build(PropertyResolver propertyResolver) { Property parentProperty = parent.build(propertyResolver); Property[] path; if (parentProperty instanceof NestedProperty) { path = ((NestedProperty)parentProperty).getPath(); System.arraycopy(path, 0, path, 0, path.length + 1); path[path.length-1] = parentProperty; } else { path = new Property[]{parentProperty}; } this.owningType = parentProperty.getType(); Property p = super.build(propertyResolver); return new NestedProperty("", p, path); }
@Test public void testNestedProperty() { String np = "start.x"; NestedProperty p = (NestedProperty) propertyResolver.getProperty(Line.class, np); Assert.assertEquals(Integer.TYPE, p.getRawType()); p = (NestedProperty) propertyResolver.getProperty(Student.class, "favoriteBook.author.name"); Assert.assertEquals(String.class, p.getRawType()); }
public List<VariableRef> getPath() { if (property != null && property.hasPath()) { Property[] propPath = property.getPath(); List<VariableRef> path; if (propPath.length > 1) { path = new ArrayList<VariableRef>(propPath.length); path.add(new VariableRef(propPath[0], name)); for (int i = 1; i < propPath.length; ++i) { Property[] nestedPath = new Property[i]; System.arraycopy(propPath, 0, nestedPath, 0, i); path.add(new VariableRef(new NestedProperty(join(propPath, ".", 0, i + 1), propPath[i], nestedPath), name)); } } else { path = Collections.singletonList(new VariableRef(propPath[0], name)); } return path; } else { return Collections.emptyList(); } }
public NestedProperty(String expression, Property property, Property[] path) { super(expression,property.getName(),property.getGetter(),property.getSetter(),property.getType(),property.getElementType(), property.getContainer()); this.path = collapse(path); this.tail = property; }
public Property build(PropertyResolver propertyResolver) { validate(propertyResolver); if (propertyType == null && propertyTypeName != null) { propertyType = TypeFactory.valueOf(propertyTypeName); } else if (propertyType == null) { propertyType = TypeFactory.TYPE_OF_OBJECT; } if (getterMethod != null) { getter = getterMethod.getName() + "()"; } if (setterMethod != null) { setter = setterMethod.getName() + "(%s)"; } Property p = new Property(expression != null ? expression : name, name, getter, setter, propertyType, elementType, container); if (path != null) { p = new NestedProperty(expression, p, path); } return p; }
/** * Creates a new NestedProperty * * @param expression * @param property * @param path */ public NestedProperty(String expression, Property property, Property[] path) { super(expression,property.getName(),property.getGetter(),property.getSetter(),property.getType(),property.getElementType(), property.getContainer()); this.path = collapse(property.getPath(), path); this.tail = property; }
@Override public NestedProperty copy() { Property[] copyPath = new Property[path.length]; for (int i=0, count = path.length; i < count; ++i) { copyPath[i] = path[i].copy(); } NestedProperty copy = new NestedProperty(this.getExpression(), super.copy(), copyPath); return copy; }
public Property build(PropertyResolver propertyResolver) { Property parentProperty = parent.build(propertyResolver); Property[] path; if (parentProperty instanceof NestedProperty) { path = ((NestedProperty)parentProperty).getPath(); System.arraycopy(path, 0, path, 0, path.length + 1); path[path.length-1] = parentProperty; } else { path = new Property[]{parentProperty}; } owningType(parentProperty.getType()); Property p = super.build(propertyResolver); return new NestedProperty("", p, path); }
public List<VariableRef> getPath() { if (property != null && property.hasPath()) { Property[] propPath = property.getPath(); List<VariableRef> path; if (propPath.length > 1) { path = new ArrayList<VariableRef>(propPath.length); path.add(new VariableRef(propPath[0], name)); String[] expr = property.getExpression().split("\\."); for (int i = 1; i < propPath.length; ++i) { Property[] nestedPath = new Property[i]; System.arraycopy(propPath, 0, nestedPath, 0, i); path.add(new VariableRef(new NestedProperty(join(expr, ".", 0, i + 1), propPath[i], nestedPath), name)); } } else { path = Collections.singletonList(new VariableRef(propPath[0], name)); } return path; } else { return Collections.emptyList(); } }
@Test public void testNestedProperty() { String np = "start.x"; NestedProperty p = (NestedProperty) propertyResolver.getProperty(Line.class, np); Assert.assertEquals(Integer.TYPE, p.getRawType()); }
return new NestedProperty(expression.toString(), property, path.toArray(new Property[path.size()]));
@Test public void testNestedProperty() { String np = "start.x"; PropertyResolverStrategy propertyResolver = UtilityResolver.getDefaultPropertyResolverStrategy(); NestedProperty p = propertyResolver.getNestedProperty(Line.class, np); Assert.assertEquals(Integer.TYPE, p.getRawType()); }
/** * Builds the property, using the specified proeprtyResolver to validate * the property settings * * @param propertyResolver * @return */ public Property build(final PropertyResolver propertyResolver) { validate(propertyResolver); if (propertyType == null && propertyTypeName != null) { propertyType = TypeFactory.valueOf(propertyTypeName); } else if (propertyType == null) { propertyType = TypeFactory.TYPE_OF_OBJECT; } if (getterMethod != null) { getter = getterMethod.getName() + "()"; } if (setterMethod != null) { setter = setterMethod.getName() + "(%s)"; } Property p = new Property(expression != null ? expression : name, name, getter, setter, propertyType, elementType, container); if (path != null) { p = new NestedProperty(expression, p, path); } return p; }
return new NestedProperty(expression.toString(), property, path.toArray(new Property[path.size()]));
elementProperty = new NestedProperty(p, elementProperty, new Property[]{owningProperty});
elementProperty = new NestedProperty(p, elementProperty, new Property[]{owningProperty});