use of net.morimekta.providence.jdbi.v2.util.NullArgument in project providence by morimekta.
the class MessageNamedArgumentFinder method find.
@Override
@SuppressWarnings("unchecked")
public Argument find(String name) {
if (!prefix.isEmpty()) {
if (name.startsWith(prefix)) {
name = name.substring(prefix.length());
} else {
return null;
}
}
String[] parts = name.split("[.]");
PMessage leaf = message;
PMessageDescriptor leafDescriptor = message.descriptor();
for (int i = 0; i < parts.length - 1; ++i) {
String part = parts[i];
PField field = leafDescriptor.findFieldByName(part);
if (field == null)
return null;
if (field.getType() != PType.MESSAGE) {
throw new IllegalArgumentException("");
}
leafDescriptor = (PMessageDescriptor) field.getDescriptor();
if (leaf != null) {
leaf = (PMessage) leaf.get(field.getId());
}
}
String leafName = parts[parts.length - 1];
PField field = leafDescriptor.findFieldByName(leafName);
if (field != null) {
if (leaf != null) {
return new MessageFieldArgument(leaf, field, getColumnType(field));
}
return new NullArgument(getColumnType(field));
}
return null;
}
Aggregations