private T convert(DataModelReflection reflection) { if (reflection == null) { return null; } return definition.toObject(reflection); } }
private T convert(DataModelReflection reflection) { if (reflection == null) { return null; } return definition.toObject(reflection); } }
static <T> Comparator<DataModelReflection> toComparator( DataModelDefinition<T> definition, Comparator<? super T> objectComparator) { if (objectComparator == null) { return null; } return (a, b) -> { T aObj = definition.toObject(a); T bObj = definition.toObject(b); return objectComparator.compare(aObj, bObj); }; }
@Override public void put(DataModelReflection model) throws IOException { T object = definition.toObject(model); output.write(object); }
@Override public GroupView<T> asView() { Map<List<Object>, List<DataModelReflection>> map = asRefMap(); Map<List<Object>, List<T>> results = new LinkedHashMap<>(); for (Map.Entry<List<Object>, List<DataModelReflection>> entry : map.entrySet()) { List<Object> key = entry.getKey(); List<DataModelReflection> refs = entry.getValue(); List<T> resolved = new ArrayList<>(refs.size()); for (DataModelReflection ref : refs) { T object = definition.toObject(ref); resolved.add(object); } results.put(key, resolved); } return new MapGroupView<>(definition, grouping, results); }
@Override public <V> DataModelSource createSource( DataModelDefinition<V> definition, DirectFileOutputDescription description, TestContext context) throws IOException { DirectIoTestHelper helper = new DirectIoTestHelper(context, description.getBasePath()); if (LOG.isDebugEnabled()) { LOG.debug(MessageFormat.format( "Retrieving Direct I/O output: {0}", //$NON-NLS-1$ description.getClass().getName())); } V object = definition.toObject(definition.newReflection().build()); ModelInput<? super V> input = helper.openInput(definition.getModelClass(), description); return new DataModelSource() { @Override public DataModelReflection next() throws IOException { if (input.readTo(object)) { return definition.toReflection(object); } return null; } @Override public void close() throws IOException { input.close(); } }; } }
private <T> void prepare( DataModelDefinition<T> definition, ModelOutput<T> output, URI source) throws IOException { try (DataModelSource input = sources.open(definition, source, context)) { if (input == null) { throw new IOException(MessageFormat.format( Messages.getString("TestDataPreparator.errorMissingDataModelSource"), //$NON-NLS-1$ source)); } while (true) { DataModelReflection next = input.next(); if (next == null) { break; } T object = definition.toObject(next); output.write(object); } } finally { output.close(); } } }
private <T> void prepare( DataModelDefinition<T> definition, ModelOutput<T> output, DataModelSourceFactory source) throws IOException { assert definition != null; assert output != null; assert source != null; try (DataModelSource input = source.createSource(definition, context)) { if (input == null) { throw new IOException(MessageFormat.format( Messages.getString("TestModerator.errorMissingDataModelSource"), //$NON-NLS-1$ source)); } while (true) { DataModelReflection next = input.next(); if (next == null) { break; } T object = definition.toObject(next); output.write(object); } } finally { output.close(); } }
private <T> void prepare0(DataModelSourceFactory factory, Class<T> type) { try { DataModelDefinition<T> definition = getTestTools().toDataModelDefinition(type); DirectIoTestHelper helper = new DirectIoTestHelper( environment.getTestContext(), description.getBasePath(), environment.getConfiguration()); helper.truncate(description.getResourcePattern()); try (ModelOutput<T> output = helper.openOutput(type, description); DataModelSource source = factory.createSource(definition, environment.getTestContext())) { while (true) { DataModelReflection r = source.next(); if (r == null) { break; } T object = definition.toObject(r); output.write(object); } } } catch (IOException e) { throw new IllegalStateException(MessageFormat.format( Messages.getString("DirectIoOperatorTester.errorFailedToInitialize"), //$NON-NLS-1$ description), e); } } }