/** * Creates a method that does a conversion from Object to the expected root type, with * a null check. */ private void implementGetRoot() { getRootMethod = plasticClass.introducePrivateMethod(PlasticUtils.toTypeName(rootType), "getRoot", SINGLE_OBJECT_ARGUMENT, null); getRootMethod.changeImplementation(new InstructionBuilderCallback() { public void doBuild(InstructionBuilder builder) { builder.loadArgument(0).dupe().when(Condition.NULL, new InstructionBuilderCallback() { public void doBuild(InstructionBuilder builder) { builder.throwException(NullPointerException.class, String.format("Root object of property expression '%s' is null.", expression)); } }); builder.checkcast(rootType).returnResult(); } }); }
public void transform(PlasticClass plasticClass) { PlasticMethod delegateMethod = plasticClass.introducePrivateMethod( PlasticUtils.toTypeName(serviceType), "delegate", null, null); delegateMethod.addAdvice(new MethodAdvice() { public void advise(MethodInvocation invocation) { invocation.setReturnValue(environment.peekRequired(serviceType)); } }); for (Method method : serviceType.getMethods()) { plasticClass.introduceMethod(method).delegateTo(delegateMethod); } plasticClass.addToString(String.format("<EnvironmentalProxy for %s>", serviceType.getName())); } });
PlasticMethod delegateMethod = plasticClass.introducePrivateMethod(propertyType.getName(), "readProperty", null, null);
PlasticMethod delegateMethod = plasticClass.introducePrivateMethod(propertyType.getName(), "readProperty", null, null);
PlasticMethod delegateMethod = plasticClass.introducePrivateMethod(interfaceTypeName, "delegate", null, null);
.injectFromInstanceContext(); PlasticMethod delegateMethod = plasticClass.introducePrivateMethod(interfaceType.getName(), "delegate", null, null);
.injectFromInstanceContext(); PlasticMethod delegateMethod = plasticClass.introducePrivateMethod(interfaceType.getName(), "delegate", null, null);
} else navMethod = plasticClass.introducePrivateMethod(PlasticUtils.toTypeName(activeClass), "navigate", SINGLE_OBJECT_ARGUMENT, null);
token); PlasticMethod delegateMethod = plasticClass.introducePrivateMethod(serviceInterface.getName(), "delegate", null, null);
token); PlasticMethod delegateMethod = plasticClass.introducePrivateMethod(serviceInterface.getName(), "delegate", null, null);