FinalValidation implements  FactoryStyleValidation { @Override public Optional<String> validateFactory() { if((attributeField.getModifiers() & Modifier.FINAL) != java.lang.reflect.Modifier.FINAL) { return Optional.of("Should be final: "+ factoryClass.getName()+"#"+attributeField.getName()); } return Optional.empty(); } FinalValidation(Class<? extends FactoryBase<?,?>> factoryClass, Field attributeField); @Override Optional<String> validateFactory();  }
@Test public void test() throws NoSuchFieldException { Optional<String> result = new FinalValidation(NotFinalFactory.class,NotFinalFactory.class.getField("stringAttribute")).validateFactory(); Assertions.assertTrue(result.isPresent()); }
@Test public void test_negative() throws NoSuchFieldException { Optional<String> result = new FinalValidation(ExampleFactoryA.class,ExampleFactoryA.class.getField("stringAttribute")).validateFactory(); Assertions.assertFalse(result.isPresent()); }