/** * This should only be called for non-public fields. This method forces a * private accessor to be generated for the field. * * @param field * A non-static field. * @return A statement for accessing the value of a field. */ public ContextualStatementBuilder exposedFieldStmt(final Statement instance, final MetaField field) { if (!field.isPublic()) { addExposedField(field); } return DecorableType.FIELD.call(instance, field, factory); }
/** * This should only be called for non-public fields. This method forces a * private accessor to be generated for the field. * * @param field * A field, static or non-static. * @return A statement for accessing the value of a field. */ public ContextualStatementBuilder exposedFieldStmt(final MetaField field) { if (!field.isPublic()) { addExposedField(field); } return DecorableType.FIELD.getAccessStatement(field, factory); }
private void runDecorators(final Injectable injectable, final InjectionContext injectionContext, final ClassStructureBuilder<?> bodyBlockBuilder) { final MetaClass type = injectable.getInjectedType(); final Set<HasAnnotations> privateAccessors = new HashSet<>(); final List<DecoratorRunnable> decoratorRunnables = new ArrayList<>(); decoratorRunnables.addAll(generateDecoratorRunnablesForType(injectionContext, type, ElementType.FIELD, bodyBlockBuilder, privateAccessors, injectable)); decoratorRunnables.addAll(generateDecoratorRunnablesForType(injectionContext, type, ElementType.PARAMETER, bodyBlockBuilder, privateAccessors, injectable)); decoratorRunnables.addAll(generateDecoratorRunnablesForType(injectionContext, type, ElementType.METHOD, bodyBlockBuilder, privateAccessors, injectable)); decoratorRunnables.addAll(generateDecoratorRunnablesForType(injectionContext, type, ElementType.TYPE, bodyBlockBuilder, privateAccessors, injectable)); decoratorRunnables.sort(null); for (final DecoratorRunnable runnable : decoratorRunnables) { runnable.run(); } for (final HasAnnotations annotated : privateAccessors) { if (annotated instanceof MetaField) { controller.addExposedField((MetaField) annotated); } else if (annotated instanceof MetaMethod) { controller.addExposedMethod((MetaMethod) annotated); } } }
/** * For public methods, fields, constructors, and parameters of public methods, * this method does nothing. Otherwise this method generates private * accessors/mutators. In the case of a parameter this method acts as if * called for the declaring method. * * This method is idempotent. * * @param annotated * A method, field, or parameter that may or may not be public. */ public void ensureMemberExposed(final HasAnnotations annotated) { final MetaClassMember member; if (annotated instanceof MetaParameter) { member = ((MetaParameter) annotated).getDeclaringMember(); } else { member = (MetaClassMember) annotated; } if (!member.isPublic()) { if (member instanceof MetaField) { addExposedField((MetaField) member); } else if (member instanceof MetaMethod) { addExposedMethod((MetaMethod) member); } else if (member instanceof MetaConstructor) { addExposedConstructor((MetaConstructor) member); } } }
controller.addExposedField(field); final String privateFieldInjectorName = getPrivateFieldAccessorName(field); createInstanceStatements.add(loadVariable("this").invoke(privateFieldInjectorName, loadVariable("instance"), loadVariable(fieldDepVarName)));
dataBinderRef = DecorableType.FIELD.getAccessStatement(field, decorable.getFactoryMetaClass()); if (!field.isPublic()) { controller.addExposedField(field);
dataBinderRef = DecorableType.FIELD.getAccessStatement(field, decorable.getFactoryMetaClass()); if (!field.isPublic()) { controller.addExposedField(field);