Skip to contentMethod: createLiteralNode(String, Object)
1: package cz.cvut.kbss.jsonld.serialization;
2:
3: import cz.cvut.kbss.jsonld.exception.JsonLdSerializationException;
4: import cz.cvut.kbss.jsonld.serialization.model.LiteralNode;
5: import cz.cvut.kbss.jsonld.serialization.model.NumericLiteralNode;
6:
7: import java.util.Date;
8:
9: class TemporalNodeFactory {
10:
11: private TemporalNodeFactory() {
12: throw new AssertionError();
13: }
14:
15: static LiteralNode createLiteralNode(String name, Object value) {
16:• assert value != null;
17:• if (value instanceof Date) {
18: final Date date = (Date) value;
19:• return name != null ? new NumericLiteralNode<>(name, date.getTime()) :
20: new NumericLiteralNode<>(date.getTime());
21: } else {
22: throw new JsonLdSerializationException(
23: "Unsupported temporal type " + value.getClass() + " of value " + value);
24: }
25: }
26: }