private void bridgeServiceMethodToFilterMethod(PlasticMethod method, final PlasticField filterField, final PlasticField nextField, final int position, MethodSignature ms, final MethodSignature fms) { method.changeImplementation(new InstructionBuilderCallback() { @Override public void doBuild(InstructionBuilder builder) { builder.loadThis().getField(filterField); int argumentIndex = 0; for (int i = 0; i < fms.getParameterTypes().length; i++) { if (i == position) { builder.loadThis().getField(nextField); } else { builder.loadArgument(argumentIndex++); } } builder.invoke(fms.getMethod()).returnResult(); } }); }
private void bridgeServiceMethodToFilterMethod(PlasticMethod method, final PlasticField filterField, final PlasticField nextField, final int position, MethodSignature ms, final MethodSignature fms) { method.changeImplementation(new InstructionBuilderCallback() { @Override public void doBuild(InstructionBuilder builder) { builder.loadThis().getField(filterField); int argumentIndex = 0; for (int i = 0; i < fms.getParameterTypes().length; i++) { if (i == position) { builder.loadThis().getField(nextField); } else { builder.loadArgument(argumentIndex++); } } builder.invoke(fms.getMethod()).returnResult(); } }); }
public void implementNoOpMethod(MethodDescription method, String format, Object... arguments) { final String message = String.format(format, arguments); plasticClass.introduceMethod(method).changeImplementation(new InstructionBuilderCallback() { public void doBuild(InstructionBuilder builder) { builder.throwException(RuntimeException.class, message); } }); }
@Override public PlasticMethod introduceMethod(MethodDescription description, InstructionBuilderCallback callback) { check(); // TODO: optimize this so that a default implementation is not created. return introduceMethod(description).changeImplementation(callback); }
@Override public PlasticMethod introduceMethod(MethodDescription description, InstructionBuilderCallback callback) { check(); // TODO: optimize this so that a default implementation is not created. return introduceMethod(description).changeImplementation(callback); }
private void implementDispatchMethod(final PlasticClass plasticClass, final boolean isRoot, final MutableComponentModel model, final Flow<EventHandlerMethod> eventHandlerMethods) plasticClass.introduceMethod(TransformConstants.DISPATCH_COMPONENT_EVENT_DESCRIPTION).changeImplementation(new InstructionBuilderCallback()
private void implementMethod(PlasticClass plasticClass, final Method method, final PlasticField commandsField) plasticClass.introduceMethod(method).changeImplementation(new InstructionBuilderCallback()
private void implementMethod(PlasticClass plasticClass, final Method method, final PlasticField commandsField) plasticClass.introduceMethod(method).changeImplementation(new InstructionBuilderCallback()
/** * 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(); } }); }
method.changeImplementation(new InstructionBuilderCallback()
method.changeImplementation(new InstructionBuilderCallback()
delegateMethod.changeImplementation(new InstructionBuilderCallback()
delegateMethod.changeImplementation(new InstructionBuilderCallback()
interfaceMethod.changeImplementation(new InstructionBuilderCallback()
delegateMethod.changeImplementation(new InstructionBuilderCallback() plasticClass.introduceMethod(WRITE_REPLACE).changeImplementation(new InstructionBuilderCallback()
delegateMethod.changeImplementation(returnCreateObject);
delegateMethod.changeImplementation(new InstructionBuilderCallback() plasticClass.introduceMethod(WRITE_REPLACE).changeImplementation(new InstructionBuilderCallback()
null, null); delegateMethod.changeImplementation(new InstructionBuilderCallback()
null, null); delegateMethod.changeImplementation(new InstructionBuilderCallback()
SINGLE_OBJECT_ARGUMENT, null); navMethod.changeImplementation(new InstructionBuilderCallback()