diff --git a/hqdm-rdf/src/main/java/uk/gov/gchq/magmacore/hqdm/rdf/HqdmObjectFactory.java b/hqdm-rdf/src/main/java/uk/gov/gchq/magmacore/hqdm/rdf/HqdmObjectFactory.java index fa4fe0a2..2b2a5680 100755 --- a/hqdm-rdf/src/main/java/uk/gov/gchq/magmacore/hqdm/rdf/HqdmObjectFactory.java +++ b/hqdm-rdf/src/main/java/uk/gov/gchq/magmacore/hqdm/rdf/HqdmObjectFactory.java @@ -18,8 +18,10 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import uk.gov.gchq.magmacore.hqdm.exception.HqdmException; @@ -65,7 +67,7 @@ public static T create(final HqdmIri hqdmType, final IRI iri) */ public static Thing create(final IRI iri, final List> pairs) throws HqdmException { try { - final List iris = new ArrayList<>(); + final Set iris = new HashSet<>(); for (final Pair pair : pairs.stream() .filter(pair -> pair.getLeft().equals(RDF_TYPE)) .filter(pair -> pair.getRight().toString().startsWith(HQDM.HQDM.getNamespace())) @@ -77,7 +79,7 @@ public static Thing create(final IRI iri, final List> pairs final Thing result; if (iris.size() == 1) { - result = mapToThing(iris.get(0).getResource(), iri); + result = mapToThing(iris.iterator().next().getResource(), iri); } else { result = DynamicObjects.create(iri.toString(), Thing.class, irisToClasses(iris)); } @@ -104,7 +106,7 @@ public static Thing create(final IRI iri, final List> pairs * @param iris List of {@link IRI}. * @return Array of Class. */ - private static java.lang.Class[] irisToClasses(final List iris) { + private static java.lang.Class[] irisToClasses(final Set iris) { final List> classes = new ArrayList<>(3); // It will be a small list so just iterate it. diff --git a/hqdm/src/main/java/uk/gov/gchq/magmacore/hqdm/services/DynamicObjects.java b/hqdm/src/main/java/uk/gov/gchq/magmacore/hqdm/services/DynamicObjects.java index 153abb27..c9f49ef4 100644 --- a/hqdm/src/main/java/uk/gov/gchq/magmacore/hqdm/services/DynamicObjects.java +++ b/hqdm/src/main/java/uk/gov/gchq/magmacore/hqdm/services/DynamicObjects.java @@ -57,12 +57,7 @@ public static U create(final String id, final */ public static U implementInterfaces(final T thing, final java.lang.Class returnType, final java.lang.Class[] classes) { - try { - return (U) Proxy.newProxyInstance(ClassServices.class.getClassLoader(), classes, new ThingHandler(thing)); - - } catch (final Exception e) { - return null; - } + return (U) Proxy.newProxyInstance(ClassServices.class.getClassLoader(), classes, new ThingHandler(thing)); } /**