methods.add(wrappedMethod);
} else if (method.getJavaMember().getName().equals("initializer")) {
AnnotatedMethodWrapper<? super Grocery> methodWrapper = new AnnotatedMethodWrapper(method, this, true);
methodWrapper.replaceParameters(new AnnotatedParameterWrapper(method.getParameters().get(0), methodWrapper, false,
new CheapLiteral()) {
@Override
public Type getBaseType() {
getBaseTypeOfInitializerTropicalFruitParameterUsed = true;
return TropicalFruit.class;
}
});
methods.add(methodWrapper);
} else if (method.getJavaMember().getName().equals("observer1")) {
Annotation[] parameterAnnotations = new Annotation[] { new Observes() {
public TransactionPhase during() {
return TransactionPhase.IN_PROGRESS;
}
public Reception notifyObserver() {
return Reception.ALWAYS;
}
public Class<? extends Annotation> annotationType() {
return Observes.class;
}
}, new CheapLiteral() };
AnnotatedMethodWrapper<? super Grocery> methodWrapper = new AnnotatedMethodWrapper(method, this, true);
methods.add(wrapMethodParameters(method.getParameters(), methodWrapper, false, parameterAnnotations));
} else if (method.getJavaMember().getName().equals("observer2")) {
AnnotatedMethodWrapper<? super Grocery> methodWrapper = new AnnotatedMethodWrapper(method, this, true);
methods.add(wrapMethodParameters(method.getParameters(), methodWrapper, true, new ExpensiveLiteral()));
} else if (method.getJavaMember().getName().equals("observerMilk")) {
AnnotatedMethodWrapper<? super Grocery> methodWrapper = new AnnotatedMethodWrapper(method, this, true);
methodWrapper.replaceParameters(new AnnotatedParameterWrapper(methodWrapper.getParameter(0), methodWrapper, true),
new AnnotatedParameterWrapper(methodWrapper.getParameter(1), methodWrapper, true) {
@Override
public Type getBaseType() {
getBaseTypeOfObserverInjectionPointUsed = true;
return TropicalFruit.class;
}
});
methods.add(methodWrapper);
} else if (method.getJavaMember().getName().equals("destroyBill")) {
AnnotatedMethodWrapper<? super Grocery> methodWrapper = new AnnotatedMethodWrapper(method, this, true);
// replace the second parameter and keep the first one
methodWrapper.replaceParameters(new AnnotatedParameterWrapper(methodWrapper.getParameter(0), methodWrapper, true),
new AnnotatedParameterWrapper(methodWrapper.getParameter(1), methodWrapper, true, AnyLiteral.INSTANCE) {
@Override
public Type getBaseType() {
getBaseTypeOfBillDisposerParameterUsed = true;
return TropicalFruit.class;
}
});
methods.add(methodWrapper);
} else if (method.getJavaMember().getName().equals("observesVegetable")) {
AnnotatedMethodWrapper<? super Grocery> methodWrapper = new AnnotatedMethodWrapper(method, this, true);
methodWrapper.replaceParameters(new AnnotatedParameterWrapper(methodWrapper.getParameter(0), methodWrapper, true) {
@Override
public Type getBaseType() {
getBaseTypeOfObserverParameterUsed = true;
return Carrot.class;
}
});
methods.add(methodWrapper);
} else if (method.getJavaMember().getName().equals("destroyVegetable")) {
AnnotatedMethodWrapper<? super Grocery> methodWrapper = new AnnotatedMethodWrapper(method, this, true);
methodWrapper.replaceParameters(new AnnotatedParameterWrapper(methodWrapper.getParameter(0), methodWrapper, true, new CheapLiteral()) {
@Override
public Type getBaseType() {
return Carrot.class;
}
});
methods.add(methodWrapper);
} else if (method.getJavaMember().getName().equals("destroyYogurt")) {
AnnotatedMethodWrapper<? super Grocery> methodWrapper = new AnnotatedMethodWrapper(method, this, true);
methodWrapper.replaceParameters(
new AnnotatedParameterWrapper(methodWrapper.getParameter(0), methodWrapper, false,
new Annotation[] { new ExpensiveLiteral(), new Disposes() {
public Class<? extends Annotation> annotationType() {
return Disposes.class;
}
} }));