NotInnerClassValidation implements FactoryStyleValidation { @Override public Optional<String> validateFactory() { boolean invalid = clazz.isMemberClass() && !Modifier.isStatic(clazz.getModifiers()); if (invalid) { return Optional.of(clazz+" is an inner class, which must not be a Factory class (Non-static nested classes are called inner classes)"); } else { return Optional.empty(); } } NotInnerClassValidation(Class<? extends FactoryBase<?,?>> clazz); @Override Optional<String> validateFactory();  }
@Test public void test(){ Optional<String> result = new NotInnerClassValidation(InnerFactory.class).validateFactory(); Assertions.assertTrue(result.isPresent()); }
@Test public void test_negative(){ Optional<String> result = new NotInnerClassValidation(ExampleFactoryA.class).validateFactory(); Assertions.assertFalse(result.isPresent()); }