use of won.shacl2java.runtime.model.GraphEntity in project webofneeds by researchstudio-sat.
the class ToRdfUtils method getAsNode.
public static Node getAsNode(Object value) {
if (value instanceof GraphEntity) {
GraphEntity entity = (GraphEntity) value;
entity.createNodeIfNecessary();
return entity.getNode();
}
if (value instanceof Boolean || value instanceof Number || value instanceof String || value instanceof XSDDateTime) {
return NodeFactory.createLiteralByValue(value, TypeMapper.getInstance().getTypeByValue(value));
}
if (value instanceof URI) {
return NodeFactory.createURI(value.toString());
}
if (value instanceof Enum) {
// if we created it, it has a getValue() method -> use that
try {
Method getValue = value.getClass().getMethod("getValue");
if (getValue != null) {
return getAsNode(getValue.invoke(value));
}
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Error converting value {} to Node", value, e);
}
}
}
if (logger.isDebugEnabled()) {
logger.debug("Could not convert value {} to Node", value);
}
return null;
}
Aggregations