/** * Retrieves an object {@link Value} from the statements in the given model. If more than one possible * object value exists, any one value is picked and returned. * * @param m * the model from which to retrieve an object value. * @return an object value from the given model, or {@link Optional#empty()} if no such value exists. */ public static Optional<Value> object(Model m) { return m.stream().map(st -> st.getObject()).findAny(); }
/** * Retrieves an object {@link Value} from the statements in the given model. If more than one possible * object value exists, any one value is picked and returned. * * @param m * the model from which to retrieve an object value. * @return an object value from the given model, or {@link Optional#empty()} if no such value exists. */ public static Optional<Value> object(Model m) { return m.stream().map(st -> st.getObject()).findAny(); }
/** * Retrieves an object {@link IRI} value from the statements in the given model. If more than one possible * IRI value exists, any one value is picked and returned. * * @param m * the model from which to retrieve an object IRI value. * @return an {@link Optional} object IRI value from the given model, which will be * {@link Optional#empty() empty} if no such value exists. */ public static Optional<IRI> objectIRI(Model m) { return m.stream().map(st -> st.getObject()).filter(o -> o instanceof IRI).map(r -> (IRI)r).findAny(); }
public static Iterable<Resource> getTypes(Model theGraph, Resource theRes) { return (Iterable)theGraph.stream().filter(Statements.matches(theRes, RDF.TYPE, (Value)null, new Resource[0])).map(Statement::getObject).map((theObject) -> { return (Resource)theObject; }).collect(Collectors.toList()); }
/** * Retrieves a subject {@link IRI} from the statements in the given model. If more than one possible IRI * value exists, any one IRI value is picked and returned. * * @param m * the model from which to retrieve a subject IRI value. * @return an {@link Optional} subject IRI value from the given model, which will be * {@link Optional#empty() empty} if no such value exists. */ public static Optional<IRI> subjectIRI(Model m) { return m.stream().map(st -> st.getSubject()).filter(s -> s instanceof IRI).map(s -> (IRI)s).findAny(); }
/** * Retrieves a subject {@link Resource} from the statements in the given model. If more than one possible * resource value exists, any one resource value is picked and returned. * * @param m * the model from which to retrieve a subject Resource. * @return an {@link Optional} subject resource from the given model, which will be * {@link Optional#empty() empty} if no such value exists. */ public static Optional<Resource> subject(Model m) { return m.stream().map(st -> st.getSubject()).findAny(); }
/** * Retrieves a predicate from the statements in the given model. If more than one possible predicate value * exists, any one value is picked and returned. * * @param m * the model from which to retrieve a predicate value. * @return an {@link Optional} predicate value from the given model, which will be {@link Optional#empty() * empty} if no such value exists. */ public static Optional<IRI> predicate(Model m) { return m.stream().map(st -> st.getPredicate()).findAny(); }
/** * Retrieves a subject {@link Resource} from the statements in the given model. If more than one possible * resource value exists, any one resource value is picked and returned. * * @param m * the model from which to retrieve a subject Resource. * @return an {@link Optional} subject resource from the given model, which will be * {@link Optional#empty() empty} if no such value exists. */ public static Optional<Resource> subject(Model m) { return m.stream().map(st -> st.getSubject()).findAny(); }
/** * Retrieves a predicate from the statements in the given model. If more than one possible predicate value * exists, any one value is picked and returned. * * @param m * the model from which to retrieve a predicate value. * @return an {@link Optional} predicate value from the given model, which will be {@link Optional#empty() * empty} if no such value exists. */ public static Optional<IRI> predicate(Model m) { return m.stream().map(st -> st.getPredicate()).findAny(); }
/** * Retrieves an object {@link Literal} value from the statements in the given model. If more than one * possible Literal value exists, any one Literal value is picked and returned. * * @param m * the model from which to retrieve an object Literal value. * @return an object Literal value from the given model, or {@link Optional#empty()} if no such value * exists. */ public static Optional<Literal> objectLiteral(Model m) { return m.stream().map(st -> st.getObject()).filter(o -> o instanceof Literal).map( l -> (Literal)l).findAny(); }
/** * Retrieves all object {@link IRI} values from the statements in the given model. * * @param m * the model from which to retrieve all object IRI values. * @return a {@link Set} containing object IRI values from the given model, which will be empty if no * such value exists. * @see Model#objects() */ public static Set<IRI> objectIRIs(Model m) { return m.stream().map(st -> st.getObject()).filter(o -> o instanceof IRI).map(r -> (IRI)r).collect( Collectors.toSet()); }
/** * Retrieves a subject {@link BNode} from the statements in the given model. If more than one possible * blank node value exists, any one blank node value is picked and returned. * * @param m * the model from which to retrieve a subject BNode value. * @return an {@link Optional} subject BNode value from the given model, which will be * {@link Optional#empty() empty} if no such value exists. */ public static Optional<BNode> subjectBNode(Model m) { return m.stream().map(st -> st.getSubject()).filter(s -> s instanceof BNode).map( s -> (BNode)s).findAny(); }
/** * Retrieves all object {@link Resource} values from the statements in the given model. * * @param m * the model from which to retrieve all object {@link Resource} values. * @return a {@link Set} containing object {@link Resource} values from the given model, which will be * empty if no such value exists. * @see Model#objects() */ public static Set<Resource> objectResources(Model m) { return m.stream().map(st -> st.getObject()).filter(o -> o instanceof Resource).map( r -> (Resource)r).collect(Collectors.toSet()); }
/** * Retrieves an object {@link IRI} value from the statements in the given model. If more than one possible * IRI value exists, any one value is picked and returned. * * @param m * the model from which to retrieve an object IRI value. * @return an {@link Optional} object IRI value from the given model, which will be * {@link Optional#empty() empty} if no such value exists. */ public static Optional<IRI> objectIRI(Model m) { return m.stream().map(st -> st.getObject()).filter(o -> o instanceof IRI).map(r -> (IRI)r).findAny(); }
/** * Retrieves a subject {@link IRI} from the statements in the given model. If more than one possible IRI * value exists, any one IRI value is picked and returned. * * @param m * the model from which to retrieve a subject IRI value. * @return an {@link Optional} subject IRI value from the given model, which will be * {@link Optional#empty() empty} if no such value exists. */ public static Optional<IRI> subjectIRI(Model m) { return m.stream().map(st -> st.getSubject()).filter(s -> s instanceof IRI).map(s -> (IRI)s).findAny(); }
/** * Retrieves all object String values from the statements in the given model. * * @param m * the model from which to retrieve all object String values. * @return a {@link Set} containing object String values from the given model, which will be empty if no * such value exists. * @see Model#objects() */ public static Set<String> objectStrings(Model m) { return m.stream().map(st -> st.getObject().stringValue()).collect(Collectors.toSet()); }
/** * Retrieves all object String values from the statements in the given model. * * @param m * the model from which to retrieve all object String values. * @return a {@link Set} containing object String values from the given model, which will be empty if no * such value exists. * @see Model#objects() */ public static Set<String> objectStrings(Model m) { return m.stream().map(st -> st.getObject().stringValue()).collect(Collectors.toSet()); }
/** * Retrieves an object value as a String from the statements in the given model. If more than one possible * object value exists, any one value is picked and returned. * * @param m * the model from which to retrieve an object String value. * @return an {@link Optional} object String value from the given model, which will be * {@link Optional#empty() empty} if no such value exists. */ public static Optional<String> objectString(Model m) { return m.stream().map(st -> st.getObject().stringValue()).findAny(); }
/** * Retrieves an object value as a String from the statements in the given model. If more than one possible * object value exists, any one value is picked and returned. * * @param m * the model from which to retrieve an object String value. * @return an {@link Optional} object String value from the given model, which will be * {@link Optional#empty() empty} if no such value exists. */ public static Optional<String> objectString(Model m) { return m.stream().map(st -> st.getObject().stringValue()).findAny(); }
public ElementVerifier<?> getTypeVerifier() throws SepaParseException { List<Statement> typeDefinitions = getModel().stream().filter(stmt -> stmt.getPredicate().equals(RDF.TYPE)).collect(Collectors.toList()); typeDefinitions.forEach(typeDef -> typeDef.getObject()); return getTypeDef(typeDefinitions.stream().filter(stmt -> ((stmt.getObject().toString().equals(ec())) || (stmt.getObject().toString().equals(epa())) || (stmt.getObject().toString().equals(ep())))).findFirst()); }