JenaUtils { public static Object literalToValue(Literal literal) { if (literal.getDatatype().equals(RDFLangString.rdfLangString)) { return new LangString(literal.getString(), literal.getLanguage()); } return literal.getDatatype().equals(XSDDatatype.XSDlong) ? literal.getLong() : literal.getValue(); } private  JenaUtils(); static RDFNode valueToRdfNode(Assertion assertion, Value<?> value); static Object literalToValue(Literal literal);  }
@Test public void literalToValueReturnsTypeRepresentedByLiteral() { assertEquals(117, JenaUtils.literalToValue(ResourceFactory.createTypedLiteral(117))); assertEquals(true, JenaUtils.literalToValue(ResourceFactory.createTypedLiteral(true))); assertEquals("test", JenaUtils.literalToValue(ResourceFactory.createTypedLiteral("test"))); }
@Test public void literalToValueTranslatesLongLiteralToJavaLong() { assertEquals(117L, JenaUtils.literalToValue(ResourceFactory.createTypedLiteral(117L))); }
@Test void literalToValueTransformsStringWithLanguageToLangString() { final Literal literal = ResourceFactory.createLangLiteral("test", "en"); final Object result = JenaUtils.literalToValue(literal); assertThat(result, instanceOf(LangString.class)); assertEquals("test", ((LangString) result).getValue()); assertTrue(((LangString) result).getLanguage().isPresent()); assertEquals("en", ((LangString) result).getLanguage().get()); }