Search code examples
javaowl

Java hashset constructor inline


I have this piece of code:

        manager.addAxiom(
            ontology,factory.getOWLSubClassOfAxiom(
                    factory.getOWLClass("CCC", prefix ),
                    factory.getOWLObjectIntersectionOf(
                            Arrays.asList(
                                    factory.getOWLObjectComplementOf(
                                            factory.getOWLClass("AAA", prefix )),
                                    factory.getOWLClass("AAA", prefix )) )))  ;

As you can see I'm using Arrays.asList to represent a list of OWLClassExpressions. This worked for OWLAPI 5, but now I have to do the same for OWLAPI4 which doesn't support List, but only Set. How can I convert this code, which means using the inline constructor for Set class?


Solution

  • You could use

    manager.addAxiom(
                ontology,factory.getOWLSubClassOfAxiom(
                        factory.getOWLClass("CCC", prefix ),
                        factory.getOWLObjectIntersectionOf(
                                new HashSet<T> (Arrays.asList(
                                        factory.getOWLObjectComplementOf(
                                                factory.getOWLClass("AAA", prefix )),
                                        factory.getOWLClass("AAA", prefix )) ))))  ;
    

    where T is the type of the array elements (e.g. OWLClassExpression).