/** * <p>Check that every member of the given list has the given rdf:type, and throw an exception if not.</p> * @param list The list to be checked * @param rdfType The rdf:type value to check for * @exception LanguageConsistencyException if any member of the list does not have <code>rdf:type <i>rdfType</i></code> */ protected void checkListMembersRdfType( RDFList list, Resource rdfType ) { if (strictMode() && ! ((Boolean) list.reduce( new RdfTypeTestFn( rdfType), Boolean.TRUE )).booleanValue()) { // not all of the members of the list are of the given type throw new LanguageConsistencyException( "The members of the given list are expected to be of rdf:type " + rdfType.toString() ); } }
/** * <p>Check that every member of the given list has the given rdf:type, and throw an exception if not.</p> * @param list The list to be checked * @param rdfType The rdf:type value to check for * @exception LanguageConsistencyException if any member of the list does not have <code>rdf:type <i>rdfType</i></code> */ protected void checkListMembersRdfType( RDFList list, Resource rdfType ) { if (strictMode() && ! ((Boolean) list.reduce( new RdfTypeTestFn( rdfType), Boolean.TRUE )).booleanValue()) { // not all of the members of the list are of the given type throw new LanguageConsistencyException( "The members of the given list are expected to be of rdf:type " + rdfType.toString() ); } }
public void testReduce() { model.read(getFileName("ontology/list5.rdf")); final RDFList root = getListRoot(model); final RDFList.ReduceFn f = new RDFList.ReduceFn() { @Override public Object reduce( final RDFNode n, final Object acc ) { return ((String) acc) + ((Resource) n).getLocalName(); } }; Assert.assertEquals( "Result of reduce should be concatentation of local names", "abcde", root.reduce(f, "")); }
public void testReduce() { model.read(getFileName("ontology/list5.rdf")); final RDFList root = getListRoot(model); final RDFList.ReduceFn f = new RDFList.ReduceFn() { @Override public Object reduce( final RDFNode n, final Object acc ) { return ((String) acc) + ((Resource) n).getLocalName(); } }; Assert.assertEquals( "Result of reduce should be concatentation of local names", "abcde", root.reduce(f, "")); }