use of org.skife.jdbi.v2.unstable.BindIn in project killbill by killbill.
the class EntitySqlDaoWrapperInvocationHandler method retrieveEntityIdsFromArguments.
private List<String> retrieveEntityIdsFromArguments(final Method method, final Object[] args) {
final Annotation[][] parameterAnnotations = getAnnotations(method);
int i = -1;
for (final Object arg : args) {
i++;
// This is true for e.g. create calls
if (arg instanceof Entity) {
return ImmutableList.<String>of(((Entity) arg).getId().toString());
}
// For Batch calls, the first argument will be of type List<Entity>
if (arg instanceof Iterable) {
final Builder<String> entityIds = extractEntityIdsFromBatchArgument((Iterable) arg);
if (entityIds != null) {
return entityIds.build();
}
}
for (final Annotation annotation : parameterAnnotations[i]) {
if (arg instanceof String && Bind.class.equals(annotation.annotationType()) && ("id").equals(((Bind) annotation).value())) {
return ImmutableList.<String>of((String) arg);
} else if (arg instanceof Collection && BindIn.class.equals(annotation.annotationType()) && ("ids").equals(((BindIn) annotation).value())) {
return ImmutableList.<String>copyOf((Collection) arg);
}
}
}
return ImmutableList.<String>of();
}
Aggregations