Java hashset constructor inline

141 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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).