private static <S, K> boolean hasKeys(ArrayList<MappingContextFactoryBuilder<S, K>> builders) { for(int i = 0; i < builders.size(); i++) { if (!builders.get(i).hasNoKeys()) return true; } return false; }
private static <S, K> boolean hasKeys(ArrayList<MappingContextFactoryBuilder<S, K>> builders) { for(int i = 0; i < builders.size(); i++) { if (!builders.get(i).hasNoKeys()) return true; } return false; }
public boolean hasNoDependentKeys() { if (!hasNoKeys()) { return false; } for(MappingContextFactoryBuilder<S, K> builder : children) { if (!builder.hasNoDependentKeys()) { return false; } } return true; }
public boolean hasNoDependentKeys() { if (!hasNoKeys()) { return false; } for(MappingContextFactoryBuilder<S, K> builder : children) { if (!builder.hasNoDependentKeys()) { return false; } } return true; }
@Test public void testEmpty() { assertTrue(builder.hasNoKeys()); assertSame(MappingContext.EMPTY_FACTORY, builder.build()); assertNotNull(builder.toString()); }
@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 })); }