@Test public void fromDocument() throws DocumentConverterException { final Document document = new Document() .append(RyaTypeDocumentConverter.DATA_TYPE, XMLSchema.DOUBLE.toString()) .append(RyaTypeDocumentConverter.VALUE, "4.5"); final RyaType ryaType = new RyaTypeDocumentConverter().fromDocument( document ); final RyaType expected = RdfToRyaConversions.convertLiteral( SimpleValueFactory.getInstance().createLiteral( 4.5 ) ); assertEquals(expected, ryaType); }
@Override public RyaType fromDocument(final Document document) throws DocumentConverterException { requireNonNull(document); if(!document.containsKey(DATA_TYPE)) { throw new DocumentConverterException("Could not convert document '" + document + "' because its '" + DATA_TYPE + "' field is missing."); } if(!document.containsKey(VALUE)) { throw new DocumentConverterException("Could not convert document '" + document + "' because its '" + VALUE + "' field is missing."); } return new RyaType( VF.createIRI( document.getString(DATA_TYPE) ), document.getString(VALUE)); }
RyaTypeDocumentConverter implements DocumentConverter<RyaType> { @Override public RyaType fromDocument(final Document document) throws DocumentConverterException { requireNonNull(document); if(!document.containsKey(DATA_TYPE)) { throw new DocumentConverterException("Could not convert document '" + document + "' because its '" + DATA_TYPE + "' field is missing."); } if(!document.containsKey(VALUE)) { throw new DocumentConverterException("Could not convert document '" + document + "' because its '" + VALUE + "' field is missing."); } return new RyaType( VF.createIRI( document.getString(DATA_TYPE) ), document.getString(VALUE)); } }
RyaTypeDocumentConverter implements DocumentConverter<RyaType> { @Override public RyaType fromDocument(final Document document) throws DocumentConverterException { requireNonNull(document); if(!document.containsKey(DATA_TYPE)) { throw new DocumentConverterException("Could not convert document '" + document + "' because its '" + DATA_TYPE + "' field is missing."); } if(!document.containsKey(VALUE)) { throw new DocumentConverterException("Could not convert document '" + document + "' because its '" + VALUE + "' field is missing."); } return new RyaType( VF.createIRI( document.getString(DATA_TYPE) ), document.getString(VALUE)); }  }
RyaTypeDocumentConverter implements DocumentConverter<RyaType> { @Override public RyaType fromDocument(final Document document) throws DocumentConverterException { requireNonNull(document); if(!document.containsKey(DATA_TYPE)) { throw new DocumentConverterException("Could not convert document '" + document + "' because its '" + DATA_TYPE + "' field is missing."); } if(!document.containsKey(VALUE)) { throw new DocumentConverterException("Could not convert document '" + document + "' because its '" + VALUE + "' field is missing."); } return new RyaType( VF.createIRI( document.getString(DATA_TYPE) ), document.getString(VALUE)); }  @Override Document toDocument(final RyaType ryaType); @Override RyaType fromDocument(final Document document); }
RyaTypeDocumentConverter implements DocumentConverter<RyaType> { @Override public RyaType fromDocument(final Document document) throws DocumentConverterException { requireNonNull(document); if(!document.containsKey(DATA_TYPE)) { throw new DocumentConverterException("Could not convert document '" + document + "' because its '" + DATA_TYPE + "' field is missing."); } if(!document.containsKey(VALUE)) { throw new DocumentConverterException("Could not convert document '" + document + "' because its '" + VALUE + "' field is missing."); } return new RyaType( VF.createIRI( document.getString(DATA_TYPE) ), document.getString(VALUE)); }  @Override Document toDocument(final RyaType ryaType); @Override RyaType fromDocument(final Document document); static final String DATA_TYPE; static final String VALUE; }