Search in sources :

Example 6 with ModelType

use of org.gradle.model.internal.type.ModelType in project gradle by gradle.

the class SpecializedMapStrategy method extract.

@Override
public <T> void extract(ModelSchemaExtractionContext<T> extractionContext) {
    ModelType<T> modelType = extractionContext.getType();
    if (!modelType.isClass()) {
        return;
    }
    Class<?> contractType = modelType.getConcreteClass();
    if (!contractType.isInterface()) {
        return;
    }
    if (contractType.getGenericInterfaces().length != 1) {
        return;
    }
    Type superType = contractType.getGenericInterfaces()[0];
    if (!(superType instanceof ParameterizedType)) {
        return;
    }
    ParameterizedType parameterizedSuperType = (ParameterizedType) superType;
    if (!parameterizedSuperType.getRawType().equals(ModelMap.class)) {
        return;
    }
    ModelType<?> elementType = ModelType.of(parameterizedSuperType.getActualTypeArguments()[0]);
    Class<?> proxyImpl;
    try {
        proxyImpl = generatedImplementationTypes.get(modelType);
    } catch (ExecutionException e) {
        throw UncheckedException.throwAsUncheckedException(e);
    }
    extractionContext.found(getModelSchema(extractionContext, elementType, proxyImpl));
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ModelType(org.gradle.model.internal.type.ModelType) NodeBackedModelMap(org.gradle.model.internal.core.NodeBackedModelMap) ModelMap(org.gradle.model.ModelMap) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ModelType (org.gradle.model.internal.type.ModelType)6 Type (java.lang.reflect.Type)3 Method (java.lang.reflect.Method)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 PropertyAccessorType (org.gradle.internal.reflect.PropertyAccessorType)2 Type (org.objectweb.asm.Type)2 Wrapper (com.google.common.base.Equivalence.Wrapper)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ExecutionException (java.util.concurrent.ExecutionException)1 JavaMethod (org.gradle.internal.reflect.JavaMethod)1 ModelMap (org.gradle.model.ModelMap)1 Mutate (org.gradle.model.Mutate)1 NodeBackedModelMap (org.gradle.model.internal.core.NodeBackedModelMap)1 DefaultRuleSourceValidationProblemCollector (org.gradle.model.internal.inspect.DefaultRuleSourceValidationProblemCollector)1 FormattingValidationProblemCollector (org.gradle.model.internal.inspect.FormattingValidationProblemCollector)1 RuleSourceValidationProblemCollector (org.gradle.model.internal.inspect.RuleSourceValidationProblemCollector)1 BridgeMethodBinding (org.gradle.model.internal.manage.binding.BridgeMethodBinding)1 DelegateMethodBinding (org.gradle.model.internal.manage.binding.DelegateMethodBinding)1 DirectMethodBinding (org.gradle.model.internal.manage.binding.DirectMethodBinding)1