@Test public void testMixedModelObjectFieldAndMethod() { PmoWithNamedModelObject pmoWithNamedModelObject = new PmoWithNamedModelObject(); Object defaultModelObject = ModelObjects .supplierFor(pmoWithNamedModelObject, ModelObject.DEFAULT_NAME).get(); Object namedModelObject = ModelObjects .supplierFor(pmoWithNamedModelObject, PmoWithNamedModelObject.MODEL_OBJECT).get(); assertThat(defaultModelObject, instanceOf(TestSub.class)); assertThat(namedModelObject, instanceOf(TestObject.class)); }
public static Supplier<Object> supplierFor(Object pmo, String modelObjectName) { Member accessMember = getModelObjectAccessMember(pmo, modelObjectName) .orElseThrow(() -> ModelObjectAnnotationException.noAnnotatedMember(pmo.getClass(), modelObjectName)); return () -> MemberAccessors.getValue(pmo, accessMember); }
ModelObjects { public static Supplier<Object> supplierFor(Object pmo, String modelObjectName) { Member accessMember = getModelObjectAccessMember(pmo, modelObjectName) .orElseThrow(() -> ModelObjectAnnotationException.noAnnotatedMember(pmo.getClass(), modelObjectName)); return () -> MemberAccessors.getValue(pmo, accessMember); } }
ModelObjects { public static Supplier<Object> supplierFor(Object pmo, String modelObjectName) { Member accessMember = getModelObjectAccessMember(pmo, modelObjectName) .orElseThrow(() -> ModelObjectAnnotationException.noAnnotatedMember(pmo.getClass(), modelObjectName)); return () -> MemberAccessors.getValue(pmo, accessMember); } private  ModelObjects(Class<?> pmoClass, String modelObjectName); }
ModelObjects { public static Supplier<Object> supplierFor(Object pmo, String modelObjectName) { Member accessMember = getModelObjectAccessMember(pmo, modelObjectName) .orElseThrow(() -> ModelObjectAnnotationException.noAnnotatedMember(pmo.getClass(), modelObjectName)); return () -> MemberAccessors.getValue(pmo, accessMember); } private  ModelObjects(Class<?> pmoClass, String modelObjectName); static Supplier<Object> supplierFor(Object pmo, String modelObjectName); static boolean isAccessible(Object pmo, String modelObjectName); }
ModelObjects { public static Supplier<Object> supplierFor(Object pmo, String modelObjectName) { Member accessMember = getModelObjectAccessMember(pmo, modelObjectName) .orElseThrow(() -> ModelObjectAnnotationException.noAnnotatedMember(pmo.getClass(), modelObjectName)); return () -> MemberAccessors.getValue(pmo, accessMember); } private  ModelObjects(Class<?> pmoClass, String modelObjectName); static Supplier<Object> supplierFor(Object pmo, String modelObjectName); static boolean isAccessible(Object pmo, String modelObjectName);  }