protected static RDFNode getUnique(Resource root, Property property) { List<RDFNode> nodes = root.listProperties(property).mapWith(getObject).toList(); if (nodes.size() == 0) return null; if (nodes.size() == 1) return nodes.get(0); throw new NotUniqueException(root, property); }
protected void checkType(Resource root, Resource type) { if (!root.hasProperty(RDF.type, type)) throw new CannotConstructException(this.getClass(), root, type); }
protected static Statement getUniqueStatement(Resource root, Property property) { List<Statement> statements = root.listProperties(property).toList(); if (statements.size() == 0) return null; if (statements.size() == 1) return statements.get(0); throw new NotUniqueException(root, property); }