Search in sources :

Example 1 with InjectedName

use of org.apache.ignite.configuration.annotation.InjectedName in project ignite-3 by apache.

the class Processor method getInterfaceGetMethodType.

/**
 * Get types for configuration classes generation.
 *
 * @param field Field.
 * @return Bundle with all types for configuration
 */
private static TypeName getInterfaceGetMethodType(VariableElement field) {
    TypeName interfaceGetMethodType = null;
    TypeName baseType = TypeName.get(field.asType());
    ConfigValue confAnnotation = field.getAnnotation(ConfigValue.class);
    if (confAnnotation != null) {
        interfaceGetMethodType = Utils.getConfigurationInterfaceName((ClassName) baseType);
    }
    NamedConfigValue namedConfigAnnotation = field.getAnnotation(NamedConfigValue.class);
    if (namedConfigAnnotation != null) {
        ClassName interfaceGetType = Utils.getConfigurationInterfaceName((ClassName) baseType);
        TypeName viewClassType = Utils.getViewName((ClassName) baseType);
        TypeName changeClassType = Utils.getChangeName((ClassName) baseType);
        interfaceGetMethodType = ParameterizedTypeName.get(ClassName.get(NamedConfigurationTree.class), interfaceGetType, viewClassType, changeClassType);
    }
    Value valueAnnotation = field.getAnnotation(Value.class);
    PolymorphicId polymorphicIdAnnotation = field.getAnnotation(PolymorphicId.class);
    InjectedName injectedNameAnnotation = field.getAnnotation(InjectedName.class);
    InternalId internalIdAnnotation = field.getAnnotation(InternalId.class);
    if (valueAnnotation != null || polymorphicIdAnnotation != null || injectedNameAnnotation != null || internalIdAnnotation != null) {
        // It is necessary to use class names without loading classes so that we won't
        // accidentally get NoClassDefFoundError
        ClassName confValueClass = ClassName.get("org.apache.ignite.configuration", "ConfigurationValue");
        TypeName genericType = baseType;
        if (genericType.isPrimitive()) {
            genericType = genericType.box();
        }
        interfaceGetMethodType = ParameterizedTypeName.get(confValueClass, genericType);
    }
    return interfaceGetMethodType;
}
Also used : NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) PolymorphicId(org.apache.ignite.configuration.annotation.PolymorphicId) TypeName(com.squareup.javapoet.TypeName) WildcardTypeName(com.squareup.javapoet.WildcardTypeName) ParameterizedTypeName(com.squareup.javapoet.ParameterizedTypeName) NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) ConfigValue(org.apache.ignite.configuration.annotation.ConfigValue) InternalId(org.apache.ignite.configuration.annotation.InternalId) InjectedName(org.apache.ignite.configuration.annotation.InjectedName) ClassName(com.squareup.javapoet.ClassName) NamedConfigValue(org.apache.ignite.configuration.annotation.NamedConfigValue) ConfigValue(org.apache.ignite.configuration.annotation.ConfigValue) Value(org.apache.ignite.configuration.annotation.Value)

Aggregations

ClassName (com.squareup.javapoet.ClassName)1 ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)1 TypeName (com.squareup.javapoet.TypeName)1 WildcardTypeName (com.squareup.javapoet.WildcardTypeName)1 ConfigValue (org.apache.ignite.configuration.annotation.ConfigValue)1 InjectedName (org.apache.ignite.configuration.annotation.InjectedName)1 InternalId (org.apache.ignite.configuration.annotation.InternalId)1 NamedConfigValue (org.apache.ignite.configuration.annotation.NamedConfigValue)1 PolymorphicId (org.apache.ignite.configuration.annotation.PolymorphicId)1 Value (org.apache.ignite.configuration.annotation.Value)1