use of net.morimekta.providence.util.ThriftContainer in project providence by morimekta.
the class JField method getProvider.
public String getProvider() throws GeneratorException {
String container = field.getAnnotationValue("container");
String containerProvider = "provider";
if (container != null) {
ThriftContainer containerType = ThriftContainer.forName(container);
switch(containerType) {
case DEFAULT:
containerProvider = "provider";
break;
case SORTED:
containerProvider = "sortedProvider";
break;
case ORDERED:
containerProvider = "orderedProvider";
break;
default:
break;
}
}
switch(field.getType()) {
case ENUM:
case MESSAGE:
return String.format(Locale.US, "%s.provider()", helper.getFieldType(field.getDescriptor()));
case LIST:
PList<?> lType = (PList<?>) field.getDescriptor();
return String.format(Locale.US, "%s.provider(%s)", PList.class.getName(), helper.getProviderName(lType.itemDescriptor()));
case SET:
PSet<?> sType = (PSet<?>) field.getDescriptor();
return String.format(Locale.US, "%s.%s(%s)", PSet.class.getName(), containerProvider, helper.getProviderName(sType.itemDescriptor()));
case MAP:
PMap<?, ?> mType = (PMap<?, ?>) field.getDescriptor();
return String.format(Locale.US, "%s.%s(%s,%s)", PMap.class.getName(), containerProvider, helper.getProviderName(mType.keyDescriptor()), helper.getProviderName(mType.itemDescriptor()));
default:
if (!(field.getDescriptor() instanceof PPrimitive)) {
throw new IllegalArgumentException("Unhandled type group " + field.getType());
}
return String.format(Locale.US, "%s.%s.provider()", PPrimitive.class.getName(), field.getDescriptor().getName().toUpperCase(Locale.US));
}
}
Aggregations