public MappedClassBuilder addProperties() { String ns = mappedClass.getUID().getNamespace(); for (Field field : mappedClass.getJavaClass().getDeclaredFields()) { if (!handled.contains(field.getName())) { Predicate predicate = new PredicateImpl("", ns, field.getName(), false); MappedPredicate mappedPredicate = new MappedPredicate(ns, predicate, null); addMappedPath(field, Collections.singletonList(mappedPredicate), predicate); } } return this; }
private MappedClassBuilder add(String propertyName, UID uid, boolean inv, Annotation... ann) { try { handled.add(propertyName); Field field = mappedClass.getJavaClass().getDeclaredField(propertyName); List<Annotation> annotations = new ArrayList<Annotation>(); Predicate predicate = new PredicateImpl("", uid.ns(), uid.ln(), inv); annotations.add(predicate); annotations.addAll(Arrays.asList(ann)); MappedPredicate mappedPredicate = new MappedPredicate(defaultNamespace, predicate, null); return addMappedPath(field, Collections.singletonList(mappedPredicate), annotations.toArray(new Annotation[annotations.size()])); } catch (SecurityException e) { throw new ConfigurationException(e); } catch (NoSuchFieldException e) { throw new ConfigurationException(e); } }
for (Predicate predicate : predicates) { predicatePath.add( new MappedPredicate(parentNs, predicate, first ? property.getName() : null)); first = false;
@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()); }