in core/src/main/java/org/apache/commons/proxy2/stub/AnnotationBuilder.java [188:219]
protected void train(A trainee)
{
WhenObject<Object> bud;
AnnotationTrainer<A> dy = this;
for (Map.Entry<String, ?> attr : members.entrySet())
{
final Method m;
try
{
m = traineeType.getDeclaredMethod(attr.getKey());
}
catch (Exception e1)
{
throw new IllegalArgumentException(String.format("Could not detect annotation member %1$s",
attr.getKey()));
}
try
{
bud = dy.when(m.invoke(trainee));
}
catch (Exception e)
{
// it must have happened on the invoke, so we didn't call
// when... it shouldn't happen, but we'll simply skip:
continue;
}
final Object value = attr.getValue();
Validate.isTrue(TypeUtils.isInstance(value, m.getReturnType()), "Value %s can not be assigned to %s",
value, m.getReturnType());
dy = bud.thenReturn(value);
}
}