use of com.palantir.dialogue.annotations.processor.data.ArgumentType.OptionalType in project dialogue by palantir.
the class ArgumentTypesResolver method getArgumentTypeImpl.
@SuppressWarnings("CyclomaticComplexity")
private Optional<ArgumentType> getArgumentTypeImpl(Element paramContext, TypeMirror actualTypeMirror) {
TypeName typeName = TypeName.get(actualTypeMirror);
Optional<OptionalType> optionalType = getOptionalType(paramContext, actualTypeMirror);
Optional<TypeMirror> listType = getListType(actualTypeMirror);
Optional<ArgumentType> mapType = getMapType(actualTypeMirror, typeName);
if (isPrimitive(typeName)) {
return Optional.of(ArgumentTypes.primitive(typeName, planSerDeMethodName(typeName), Optional.empty()));
} else if (listType.map(innerType -> isPrimitive(TypeName.get(innerType))).orElse(false)) {
TypeName innerTypeName = TypeName.get(listType.get());
return Optional.of(ArgumentTypes.primitive(typeName, planSerDeMethodName(innerTypeName), Optional.of(innerTypeName)));
} else if (isRawRequestBody(actualTypeMirror)) {
return Optional.of(ArgumentTypes.rawRequestBody(TypeName.get(actualTypeMirror)));
} else if (optionalType.isPresent()) {
// TODO(12345): We only want to go one level down: don't allow Optional<Optional<Type>>.
return Optional.of(ArgumentTypes.optional(typeName, optionalType.get()));
} else if (mapType.isPresent()) {
return mapType;
} else {
return Optional.of(ArgumentTypes.customType(typeName));
}
}
Aggregations