@Override public MappingContext<? super ResultSet> newMappingContext(ResultSet resultSet) throws SQLException { return mappingContextFactory.newContext(); }
@Override public MappingContext<? super ResultSet> newMappingContext(ResultSet resultSet) throws SQLException { return mappingContextFactory.newContext(); }
@Override public MappingContext<? super ResultSet> newMappingContext(ResultSet resultSet) throws SQLException { return mappingContextFactory.newContext(); }
private MappingContext<? super Row> newMappingContext() { return mappingContextFactory.newContext(); } }
public MappingContext<? super S> newMappingContext() { return mappingContextFactory.newContext(); }
@Override public MappingContext<S> newContext() { return new BreakDetectorMappingContext<S>(rootKeyDefinition, delegateFactory.newContext(), keyDefinitions); }
@Override public E map(R record) { return mapper.map(record, mappingContextFactory.newContext()); }
@Override public T map(S source) throws MappingException { return delegate.map(source, mappingContextFactory.newContext()); }
@Override protected T map(Tuple row) { return mapper.map(row, mappingContextFactory.newContext()); }
@Override public E map(R record) { return mapper.map(record, mappingContextFactory.newContext()); }
@Override public T map(ResultSet source) throws MappingException { return sourceFieldMapper.map(source, mappingContextFactory.newContext()); }
@Override public T map(S source) throws MappingException { return delegate.map(source, mappingContextFactory.newContext()); }
@Override public final Enumerable<T> enumerate(ROWS source) throws EX { return new JoinMapperEnumerable<ROW, T>(mapper, mappingContextFactory.newContext(), enumerateRows(source)); }
@Override public final Enumerable<T> enumerate(SET source) throws E { return new StaticMapperEnumerable<ROW, T>(mapper, mappingContextFactory.newContext(), enumerableFactory.newInstance(source)); }
@Override public final Enumerable<T> enumerate(ROWS source) throws EX { return new JoinMapperEnumerable<ROW, T>(mapper, mappingContextFactory.newContext(), enumerateRows(source)); }
@Override public final Enumerable<T> enumerate(SET source) throws E { return new StaticMapperEnumerable<ROW, T>(mapper, mappingContextFactory.newContext(), enumerableFactory.newInstance(source)); }
@Test public void testKeysWithSubBuilder() { builder.addKey(new KeyAndPredicate<Object[], SampleFieldKey>(new SampleFieldKey("k1", 0), null)); MappingContextFactoryBuilder<Object[], SampleFieldKey> subBuilder = builder.newBuilder(Arrays.asList(new KeyAndPredicate<Object[], SampleFieldKey>(new SampleFieldKey("k2", 3), null)), null); subBuilder.newBuilder(Arrays.asList(new KeyAndPredicate<Object[], SampleFieldKey>(new SampleFieldKey("k3", 6), null)), null); MappingContextFactory<Object[]> mappingContextFactory = builder.build(); MappingContext<Object[]> mappingContext = mappingContextFactory.newContext(); }
@Test public void testSuppliers() { int i = builder.addSupplier(new ConstantSupplier<String>("hh")); assertTrue(builder.hasNoKeys()); MappingContextFactory<Object[]> mappingContextFactory = builder.build(); assertTrue(mappingContextFactory instanceof ValuedMappingContextFactory); assertEquals("hh", mappingContextFactory.newContext().context(i)); }
@Test public void testKeysAndSuppliers() { int i = builder.addSupplier( new ConstantSupplier<String>("hh")); builder.addKey(new KeyAndPredicate<Object[], SampleFieldKey>(new SampleFieldKey("k1", 0), null)); assertFalse(builder.hasNoKeys()); MappingContextFactory<Object[]> mappingContextFactory = builder.build(); assertTrue(mappingContextFactory instanceof BreakDetectorMappingContextFactory); assertEquals("hh", mappingContextFactory.newContext().context(i)); }
@Test public void testKeys() throws Exception { builder.addKey(new KeyAndPredicate<Object[], SampleFieldKey>(new SampleFieldKey("k1", 0), null)); assertFalse(builder.hasNoKeys()); MappingContextFactory<Object[]> mappingContextFactory = builder.build(); assertTrue(mappingContextFactory instanceof BreakDetectorMappingContextFactory); assertNull(mappingContextFactory.newContext().context(0)); assertTrue(builder.nullChecker().test(new Object[] { null})); assertFalse(builder.nullChecker().test(new Object[] { 123 })); }