@Test public void testUnion() { MockFactory factory = new MockFactory(BioPAXLevel.L3); Model model = factory.createModel(); Protein p1 = model.addNew(Protein.class, "P1"); ProteinReference r1 = model.addNew(ProteinReference.class, "R1"); p1.setEntityReference(r1); Dna dna1 = model.addNew(Dna.class, "DNA1"); DnaReference dnar1 = model.addNew(DnaReference.class, "DNAR1"); dna1.setEntityReference(dnar1); BioSource human = model.addNew(BioSource.class, "human"); human.setStandardName("Homo Sapiens"); BioSource alien = model.addNew(BioSource.class, "alien"); alien.setStandardName("Green Oval Heads"); dnar1.setOrganism(human); r1.setOrganism(alien); Complex complex = model.addNew(Complex.class, "complex"); complex.addComponent(dna1); complex.addComponent(p1); PathAccessor pa = new PathAccessor("Complex/component/entityReference/organism", BioPAXLevel.L3); Set valueFromBean = pa.getValueFromBean(complex); assertTrue(valueFromBean.containsAll(Arrays.asList(human,alien))); assertTrue(valueFromBean.size()==2); }
@Override public Set getValueFromBean(D bean) throws IllegalBioPAXArgumentException { CompositeSet valueFromBean =new CompositeSet(); for (PropertyAccessor atomicAccessor : union) { if(atomicAccessor.getDomain().isAssignableFrom(bean.getModelInterface())) { valueFromBean.addComposited(atomicAccessor.getValueFromBean(bean)); } } return valueFromBean; }
UnionPropertyAccessor extends PropertyAccessorAdapter<D,R> { @Override public Set getValueFromBean(D bean) throws IllegalBioPAXArgumentException { CompositeSet valueFromBean =new CompositeSet(); for (PropertyAccessor atomicAccessor : union) { if(atomicAccessor.getDomain().isAssignableFrom(bean.getModelInterface())) { valueFromBean.addComposited(atomicAccessor.getValueFromBean(bean)); } } return valueFromBean; } }
UnionPropertyAccessor extends PropertyAccessorAdapter<D,R> { @Override public Set getValueFromBean(D bean) throws IllegalBioPAXArgumentException { CompositeSet valueFromBean =new CompositeSet(); for (PropertyAccessor atomicAccessor : union) { if(atomicAccessor.getDomain().isAssignableFrom(bean.getModelInterface())) { valueFromBean.addComposited(atomicAccessor.getValueFromBean(bean)); } } return valueFromBean; } UnionPropertyAccessor(Set<PropertyAccessor<? extends D, ? extends R>> union, Class<D> domain); }
UnionPropertyAccessor extends PropertyAccessorAdapter<D,R> { @Override public Set getValueFromBean(D bean) throws IllegalBioPAXArgumentException { CompositeSet valueFromBean =new CompositeSet(); for (PropertyAccessor atomicAccessor : union) { if(atomicAccessor.getDomain().isAssignableFrom(bean.getModelInterface())) { valueFromBean.addComposited(atomicAccessor.getValueFromBean(bean)); } } return valueFromBean; } UnionPropertyAccessor(Set<PropertyAccessor<? extends D, ? extends R>> union, Class<D> domain); @Override Set getValueFromBean(D bean); @Override boolean isUnknown(Object value); }
UnionPropertyAccessor extends PropertyAccessorAdapter<D,R> { @Override public Set getValueFromBean(D bean) throws IllegalBioPAXArgumentException { CompositeSet valueFromBean =new CompositeSet(); for (PropertyAccessor atomicAccessor : union) { if(atomicAccessor.getDomain().isAssignableFrom(bean.getModelInterface())) { valueFromBean.addComposited(atomicAccessor.getValueFromBean(bean)); } } return valueFromBean; } UnionPropertyAccessor(Set<PropertyAccessor<? extends D, ? extends R>> union, Class<D> domain); @Override Set getValueFromBean(D bean); @Override boolean isUnknown(Object value);  }