private void transformField(PlasticField field) { if (Modifier.isFinal(field.getModifiers())) return; ComputedValue<FieldConduit<Object>> computed = createComputedFieldConduit(field); field.setComputedConduit(computed); }
private void convertAccessToField(PlasticField field, String id) { String fieldName = field.getName(); ComputedValue<FieldConduit<Object>> computedConduit = createProviderForEmbeddedComponentConduit(fieldName, id); field.setComputedConduit(computedConduit); }
private void replaceFieldAccessWithMixin(PlasticField field, String mixinClassName) { ComputedValue<FieldConduit<Object>> provider = createMixinFieldProvider(field.getName(), mixinClassName); field.setComputedConduit(provider); }
private void transformField(PlasticField field) { InjectContainer annotation = field.getAnnotation(InjectContainer.class); field.claim(annotation); ComputedValue<FieldConduit<Object>> provider = createFieldValueConduitProvider(field); field.setComputedConduit(provider); }
private void makeFieldPersistent(PlasticField field, MutableComponentModel model) { Persist annotation = field.getAnnotation(Persist.class); field.claim(annotation); final String logicalFieldName = model.setFieldPersistenceStrategy(field.getName(), annotation.value()); final Object defaultValue = determineDefaultValueFromFieldType(field); ComputedValue<FieldConduit<Object>> computed = new ComputedValue<FieldConduit<Object>>() { public FieldConduit<Object> get(InstanceContext context) { InternalComponentResources resources = context.get(InternalComponentResources.class); return new PersistentFieldConduit(resources, logicalFieldName, defaultValue); } }; field.setComputedConduit(computed); }
public void transform(PlasticClass plasticClass, TransformationSupport support, MutableComponentModel model) { for (PlasticField field : plasticClass.getFieldsWithAnnotation(InjectComponent.class)) { InjectComponent annotation = field.getAnnotation(InjectComponent.class); field.claim(annotation); final String type = field.getTypeName(); final String componentId = getComponentId(field, annotation); final String fieldName = field.getName(); ComputedValue<FieldConduit<Object>> provider = new ComputedValue<FieldConduit<Object>>() { public FieldConduit<Object> get(InstanceContext context) { ComponentResources resources = context.get(ComponentResources.class); return new InjectedComponentFieldValueConduit(resources, fieldName, type, componentId); } }; field.setComputedConduit(provider); } }
private void transform(final String componentClassName, PlasticField field) { Environmental annotation = field.getAnnotation(Environmental.class); field.claim(annotation); final String fieldName = field.getName(); final Class fieldType = classCache.forName(field.getTypeName()); final boolean required = annotation.value(); ComputedValue<FieldConduit<Object>> provider = new ComputedValue<FieldConduit<Object>>() { public FieldConduit<Object> get(InstanceContext context) { return new EnvironmentalConduit(componentClassName, fieldName, fieldType, required); } public void set(Object instance, InstanceContext context, Object newValue) { throw new RuntimeException( String.format("Field %s of component %s is read only.", fieldName, componentClassName)); } }; field.setComputedConduit(provider); }
private void convertFieldIntoContainerBoundParameter(PlasticField field) { BindParameter annotation = field.getAnnotation(BindParameter.class); field.claim(annotation); final String[] possibleNames = annotation.value(); final String fieldTypeName = field.getTypeName(); final String fieldName = field.getName(); ComputedValue<FieldConduit<Object>> computedConduit = new ComputedValue<FieldConduit<Object>>() { public FieldConduit<Object> get(InstanceContext context) { ComponentResources resources = context.get(ComponentResources.class); try { return createConduit(resources, fieldTypeName, fieldName, possibleNames); } catch (Exception ex) { throw new TapestryException(String.format( "Failure binding parameter field '%s' of mixin %s (type %s): %s", fieldName, resources .getCompleteId(), resources.getComponentModel().getComponentClassName(), ExceptionUtils.toMessage(ex)), ex); } } }; field.setComputedConduit(computedConduit); }
private void convertFieldIntoParameter(PlasticClass plasticClass, MutableComponentModel model, PlasticField field) { Parameter annotation = field.getAnnotation(Parameter.class); String fieldType = field.getTypeName(); String parameterName = getParameterName(field.getName(), annotation.name()); field.claim(annotation); model.addParameter(parameterName, annotation.required(), annotation.allowNull(), annotation.defaultPrefix(), annotation.cache()); MethodHandle defaultMethodHandle = findDefaultMethodHandle(plasticClass, parameterName); ComputedValue<FieldConduit<Object>> computedParameterConduit = createComputedParameterConduit(parameterName, fieldType, annotation, defaultMethodHandle); field.setComputedConduit(computedParameterConduit); }