@Override public Format get(MappingContext<? super S> target) throws Exception { return target.context(index); } }
@Override public <T> T context(int i) { return delegateContext.context(i); }
@Override public Format get(MappingContext<? super S> target) throws Exception { return target.context(index); } }
@Override public <T> T context(int i) { return delegateContext.context(i); }
@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 })); }