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; }
public MappedClassBuilder addMixin(String propertyName) { try { handled.add(propertyName); Field field = mappedClass.getJavaClass().getDeclaredField(propertyName); Mixin mixin = new MixinImpl(); return addMappedPath(field, Collections.<MappedPredicate> emptyList(), mixin); } catch (SecurityException e) { throw new ConfigurationException(e); } catch (NoSuchFieldException e) { throw new ConfigurationException(e); } }
public MappedClassBuilder addId(String propertyName) { try { handled.add(propertyName); Field field = mappedClass.getJavaClass().getDeclaredField(propertyName); Id id; if (field.getType().equals(ID.class)) { id = new IdImpl(IDType.RESOURCE); } else if (field.getType().equals(UID.class)) { id = new IdImpl(IDType.URI); } else { id = new IdImpl(IDType.LOCAL); } return addMappedPath(field, Collections.<MappedPredicate> emptyList(), id); } catch (SecurityException e) { throw new ConfigurationException(e); } catch (NoSuchFieldException e) { throw new ConfigurationException(e); } }
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); } }