@Test public void testNewLiteral$nonTemporal$notSerializable() { NotSerializableData data = new NotSerializableData(); Literal<? extends Serializable> literal = Literals.newLiteral(data); assertThat(literal.get(),equalTo((Serializable)data.toString())); if(literal instanceof TypedLiteral<?>) { assertThat(((TypedLiteral<?>)literal).type(),equalTo(Datatypes.STRING)); } }
public static Literal<? extends Serializable> newLiteral(Object value) { checkNotNull(value,LITERAL_VALUE_CANNOT_BE_NULL); Literal<? extends Serializable> result=null; if(isDuration(value)) { result=coherceDuration(value); } else if(isDateTime(value)) { result=coherceDateTime(value,Datatypes.DATE_TIME); } else if(value instanceof Serializable) { result=new ImmutableLiteral<Serializable>((Serializable)value); } else { result=new ImmutableTypedLiteral<String>(value.toString(),Datatypes.STRING); } return result; }
Literals { public static Literal<? extends Serializable> newLiteral(Object value) { checkNotNull(value,LITERAL_VALUE_CANNOT_BE_NULL); Literal<? extends Serializable> result=null; if(isDuration(value)) { result=coherceDuration(value); } else if(isDateTime(value)) { result=coherceDateTime(value,Datatypes.DATE_TIME); } else if(value instanceof Serializable) { result=new ImmutableLiteral<Serializable>((Serializable)value); } else { result=new ImmutableTypedLiteral<String>(value.toString(),Datatypes.STRING); } return result; } }
Literals { public static Literal<? extends Serializable> newLiteral(Object value) { checkNotNull(value,LITERAL_VALUE_CANNOT_BE_NULL); Literal<? extends Serializable> result=null; if(isDuration(value)) { result=coherceDuration(value); } else if(isDateTime(value)) { result=coherceDateTime(value,Datatypes.DATE_TIME); } else if(value instanceof Serializable) { result=new ImmutableLiteral<Serializable>((Serializable)value); } else { result=new ImmutableTypedLiteral<String>(value.toString(),Datatypes.STRING); } return result; } private  Literals(); }
Literals { public static Literal<? extends Serializable> newLiteral(Object value) { checkNotNull(value,LITERAL_VALUE_CANNOT_BE_NULL); Literal<? extends Serializable> result=null; if(isDuration(value)) { result=coherceDuration(value); } else if(isDateTime(value)) { result=coherceDateTime(value,Datatypes.DATE_TIME); } else if(value instanceof Serializable) { result=new ImmutableLiteral<Serializable>((Serializable)value); } else { result=new ImmutableTypedLiteral<String>(value.toString(),Datatypes.STRING); } return result; } private  Literals(); static Literal<String> of(String value); static DurationLiteral of(javax.xml.datatype.Duration duration); static DurationLiteral of(Duration duration); static DateTimeDateTimeLiteralBuilder of(Date date); static DateTimeLiteral of(java.sql.Date date); static DateTimeLiteral of(java.sql.Time time); static DateTimeDateTimeLiteralBuilder of(Calendar calendar); static DateTimeDateTimeLiteralBuilder of(GregorianCalendar calendar); static XMLGregorianCalendarDateTimeLiteralBuilder of(XMLGregorianCalendar calendar); static DateTimeDateTimeLiteralBuilder of(DateTime dateTime); static DurationLiteral duration(long time, TimeUnit unit); static Literal<? extends Serializable> newLiteral(Object value); static TypedLiteral<? extends Serializable> newTypedLiteral(Object value, URI datatype); static LanguageLiteral newLanguageLiteral(String value, String language); }
Literals { public static Literal<? extends Serializable> newLiteral(Object value) { checkNotNull(value,LITERAL_VALUE_CANNOT_BE_NULL); Literal<? extends Serializable> result=null; if(isDuration(value)) { result=coherceDuration(value); } else if(isDateTime(value)) { result=coherceDateTime(value,Datatypes.DATE_TIME); } else if(value instanceof Serializable) { result=new ImmutableLiteral<Serializable>((Serializable)value); } else { result=new ImmutableTypedLiteral<String>(value.toString(),Datatypes.STRING); } return result; } private  Literals(); static Literal<String> of(String value); static DurationLiteral of(javax.xml.datatype.Duration duration); static DurationLiteral of(Duration duration); static DateTimeDateTimeLiteralBuilder of(Date date); static DateTimeLiteral of(java.sql.Date date); static DateTimeLiteral of(java.sql.Time time); static DateTimeDateTimeLiteralBuilder of(Calendar calendar); static DateTimeDateTimeLiteralBuilder of(GregorianCalendar calendar); static XMLGregorianCalendarDateTimeLiteralBuilder of(XMLGregorianCalendar calendar); static DateTimeDateTimeLiteralBuilder of(DateTime dateTime); static DurationLiteral duration(long time, TimeUnit unit); static Literal<? extends Serializable> newLiteral(Object value); static TypedLiteral<? extends Serializable> newTypedLiteral(Object value, URI datatype); static LanguageLiteral newLanguageLiteral(String value, String language);  }