@Test public void mapper_havingMethodWithMultiplePropertyAnnotations_MapsCorrectly() { prepareTest(); CarmlMapper mapper = new CarmlMapper(); Person manu = mapper.map(model, (Resource) VF.createIRI("http: ImmutableSet.of(Person.class)); Set<Person> acquaintances = manu.getKnows(); assertThat(acquaintances, hasSize(6)); }
@Override public <T> T map(Model model, Resource resource, Set<Type> types) { if (types.size() > 1) { if (!types.stream().allMatch(t -> ((Class<?>)t).isInterface())) { throw new IllegalStateException(String.format( "Error mapping %s. In case of multiple types, mapper requires all types to be interfaces", formatResourceForLog(model, resource, namespaces, true))); } } if (types.stream().allMatch(t -> ((Class<?>)t).isInterface())) { return doMultipleInterfaceMapping(model, resource, types); } else { return doSingleTypeConcreteClassMapping(model, resource, Iterables.getOnlyElement(types)); } }
CarmlMapper implements Mapper, MappingCache { @Override public <T> T map(Model model, Resource resource, Set<Type> types) { if (types.size() > 1) { if (!types.stream().allMatch(t -> ((Class<?>)t).isInterface())) { throw new IllegalStateException(String.format( "Error mapping %s. In case of multiple types, mapper requires all types to be interfaces", formatResourceForLog(model, resource, namespaces, true))); } } if (types.stream().allMatch(t -> ((Class<?>)t).isInterface())) { return doMultipleInterfaceMapping(model, resource, types); } else { return doSingleTypeConcreteClassMapping(model, resource, Iterables.getOnlyElement(types)); } } }
CarmlMapper implements Mapper, MappingCache { @Override public <T> T map(Model model, Resource resource, Set<Type> types) { if (types.size() > 1) { if (!types.stream().allMatch(t -> ((Class<?>)t).isInterface())) { throw new IllegalStateException(String.format( "Error mapping %s. In case of multiple types, mapper requires all types to be interfaces", formatResourceForLog(model, resource, namespaces, true))); } } if (types.stream().allMatch(t -> ((Class<?>)t).isInterface())) { return doMultipleInterfaceMapping(model, resource, types); } else { return doSingleTypeConcreteClassMapping(model, resource, Iterables.getOnlyElement(types)); } } CarmlMapper();  CarmlMapper(Set<Namespace> namespaces); }
CarmlMapper implements Mapper, MappingCache { @Override public <T> T map(Model model, Resource resource, Set<Type> types) { if (types.size() > 1) { if (!types.stream().allMatch(t -> ((Class<?>)t).isInterface())) { throw new IllegalStateException(String.format( "Error mapping %s. In case of multiple types, mapper requires all types to be interfaces", formatResourceForLog(model, resource, namespaces, true))); } } if (types.stream().allMatch(t -> ((Class<?>)t).isInterface())) { return doMultipleInterfaceMapping(model, resource, types); } else { return doSingleTypeConcreteClassMapping(model, resource, Iterables.getOnlyElement(types)); } } CarmlMapper();  CarmlMapper(Set<Namespace> namespaces); @Override T map(Model model, Resource resource, Set<Type> types); @Override Object getCachedMapping(Resource resource, Set<Type> targetType); @Override void addCachedMapping(Resource resource, Set<Type> targetType, Object value); @Override Type getDecidableType(IRI rdfType); @Override void addDecidableType(IRI rdfType, Type type); @Override void bindInterfaceImplementation(Type interfaze, Type implementation); @Override Type getInterfaceImplementation(Type interfaze); }
CarmlMapper implements Mapper, MappingCache { @Override public <T> T map(Model model, Resource resource, Set<Type> types) { if (types.size() > 1) { if (!types.stream().allMatch(t -> ((Class<?>)t).isInterface())) { throw new IllegalStateException(String.format( "Error mapping %s. In case of multiple types, mapper requires all types to be interfaces", formatResourceForLog(model, resource, namespaces, true))); } } if (types.stream().allMatch(t -> ((Class<?>)t).isInterface())) { return doMultipleInterfaceMapping(model, resource, types); } else { return doSingleTypeConcreteClassMapping(model, resource, Iterables.getOnlyElement(types)); } } CarmlMapper();  CarmlMapper(Set<Namespace> namespaces); @Override T map(Model model, Resource resource, Set<Type> types); @Override Object getCachedMapping(Resource resource, Set<Type> targetType); @Override void addCachedMapping(Resource resource, Set<Type> targetType, Object value); @Override Type getDecidableType(IRI rdfType); @Override void addDecidableType(IRI rdfType, Type type); @Override void bindInterfaceImplementation(Type interfaze, Type implementation); @Override Type getInterfaceImplementation(Type interfaze);  }