@Nullable private MappedPath getMappedPath(MappedProperty<?> property, @Nullable List<MappedPredicate> path) { property.resolve(null); if (path != null) { return new MappedPath(property, path, false); } else { if (property.isAnnotatedProperty()) { return new MappedPath(property, Collections.<MappedPredicate> emptyList(), false); } else { return null; } } }
private MappedClassBuilder addMappedPath(Field field, List<MappedPredicate> predicates, Annotation... annotations) { FieldProperty fieldProperty = new FieldProperty(field, annotations, mappedClass); fieldProperty.resolve(mappedClass); MappedPath mappedPath = new MappedPath(fieldProperty, predicates, false); mappedClass.addMappedPath(mappedPath); return this; }
public Configuration build() { if (converterRegistry == null) { converterRegistry = new ConverterRegistryImpl(); } // populate mappedSuperClasses for (MappedClass mappedClass : mappedClasses.values()) { if (!mappedClass.getJavaClass().getSuperclass().equals(Object.class)) { MappedClass mappedSuperClass = mappedClasses.get(mappedClass.getJavaClass().getSuperclass()); if (mappedSuperClass != null) { mappedClass.getMappedSuperClasses().add(mappedSuperClass); } } } // merge data for (MappedClass mappedClass : mappedClasses.values()) { Deque<MappedClass> supers = new ArrayDeque<MappedClass>(mappedClass.getMappedSuperClasses()); while (!supers.isEmpty()) { MappedClass mappedSuperClass = supers.pop(); supers.addAll(mappedSuperClass.getMappedSuperClasses()); for (MappedPath path : mappedSuperClass.getProperties()) { MappedProperty<?> property = (MappedProperty<?>) path.getMappedProperty().clone(); property.resolve(mappedClass); mappedClass.addMappedPath(new MappedPath(property, path.getPredicatePath(), !mappedClass.equals(property.getDeclaringClass()))); } } } return new SimpleConfiguration(converterRegistry, new HashSet<MappedClass>(mappedClasses.values())); }
@Test public void ToString() throws SecurityException, NoSuchMethodException { Configuration configuration = new DefaultConfiguration(TEST.NS, MappedPathTest.class); MappedClass mappedClass = configuration.getMappedClass(MappedPathTest.class); MethodProperty property = new MethodProperty(MappedPathTest.class.getMethod("getProperty"), mappedClass); MappedPredicate predicate = new MappedPredicate(TEST.NS, new DummyPredicate(RDF.type), null); MappedPath path = new MappedPath(property, Collections.<MappedPredicate> singletonList(predicate), false); assertEquals("public java.lang.String com.mysema.rdfbean.object.MappedPathTest.getProperty() { http://www.w3.org/1999/02/22-rdf-syntax-ns#type }", path.toString()); }
MappedProperty<?> property = (MappedProperty<?>) path.getMappedProperty().clone(); property.resolve(mappedClass); mappedClass.addMappedPath(new MappedPath(property, path.getPredicatePath(), !mappedClass.equals(property.getDeclaringClass())));