當前位置: 首頁>>代碼示例>>Java>>正文


Java ModelReference類代碼示例

本文整理匯總了Java中org.gradle.model.internal.core.ModelReference的典型用法代碼示例。如果您正苦於以下問題:Java ModelReference類的具體用法?Java ModelReference怎麽用?Java ModelReference使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ModelReference類屬於org.gradle.model.internal.core包,在下文中一共展示了ModelReference類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toInputBuilder

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
private UnboundRuleInput.Builder toInputBuilder(ModelBinding binding) {
    ModelReference<?> reference = binding.getPredicate().getReference();
    UnboundRuleInput.Builder builder = UnboundRuleInput.type(reference.getType());
    ModelPath path;
    if (binding.isBound()) {
        builder.bound();
        path = binding.getNode().getPath();
    } else {
        path = reference.getPath();
        if (path != null) {
            builder.suggestions(CollectionUtils.stringize(suggestionsProvider.transform(path)));
        }
        ModelPath scope = reference.getScope();
        if (scope != null && !scope.equals(ModelPath.ROOT)) {
            builder.scope(scope.toString());
        }
    }
    if (path != null) {
        builder.path(path);
    }
    builder.description(reference.getDescription());
    return builder;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:24,代碼來源:UnboundRulesProcessor.java

示例2: apply

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
public void apply(ProjectInternal project) {
    project.getPluginManager().apply(BasePlugin.class);
    project.getPluginManager().apply(ReportingBasePlugin.class);
    project.getPluginManager().apply(LanguageBasePlugin.class);
    project.getPluginManager().apply(BinaryBasePlugin.class);

    JavaPluginConvention javaConvention = new JavaPluginConvention(project, instantiator);
    project.getConvention().getPlugins().put("java", javaConvention);

    configureCompileDefaults(project, javaConvention);
    BridgedBinaries binaries = configureSourceSetDefaults(javaConvention);

    modelRegistry.register(ModelRegistrations.bridgedInstance(ModelReference.of("bridgedBinaries", BridgedBinaries.class), binaries)
        .descriptor("JavaBasePlugin.apply()")
        .hidden(true)
        .build());

    configureJavaDoc(project, javaConvention);
    configureTest(project, javaConvention);
    configureBuildNeeded(project);
    configureBuildDependents(project);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:23,代碼來源:JavaBasePlugin.java

示例3: doRegister

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
private <R, S extends BinarySpec> void doRegister(MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry, RuleSourceDependencies dependencies) {
    try {
        RuleMethodDataCollector dataCollector = new RuleMethodDataCollector();
        visitAndVerifyMethodSignature(dataCollector, ruleDefinition);

        final Class<S> binaryType = dataCollector.getParameterType(BinarySpec.class);
        final Class<? extends ComponentSpec> componentType = dataCollector.getParameterType(ComponentSpec.class);
        dependencies.add(ComponentModelBasePlugin.class);
        final ModelReference<BinaryContainer> subject = ModelReference.of(ModelPath.path("binaries"), new ModelType<BinaryContainer>() {
        });

        configureMutationRule(modelRegistry, subject, componentType, binaryType, ruleDefinition);
    } catch (InvalidComponentModelException e) {
        invalidModelRule(ruleDefinition, e);
    }
}
 
開發者ID:Pushjet,項目名稱:Pushjet-Android,代碼行數:17,代碼來源:ComponentBinariesRuleDefinitionHandler.java

示例4: doRegister

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
private <R, S extends BinarySpec> void doRegister(MethodRuleDefinition<R> ruleDefinition, ModelRegistry modelRegistry, RuleSourceDependencies dependencies) {
    try {
        RuleMethodDataCollector dataCollector = new RuleMethodDataCollector();
        verifyMethodSignature(dataCollector, ruleDefinition);

        Class<S> binaryType =  dataCollector.getParameterType(BinarySpec.class);
        dependencies.add(ComponentModelBasePlugin.class);

        final ModelReference<TaskContainer> tasks = ModelReference.of(ModelPath.path("tasks"), new ModelType<TaskContainer>() {
        });

        modelRegistry.mutate(new BinaryTaskRule<R, S>(tasks, binaryType, ruleDefinition, modelRegistry));

    } catch (InvalidComponentModelException e) {
        invalidModelRule(ruleDefinition, e);
    }
}
 
開發者ID:Pushjet,項目名稱:Pushjet-Android,代碼行數:18,代碼來源:BinaryTasksRuleDefinitionHandler.java

示例5: visitDependency

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
protected <R, S> void visitDependency(RuleMethodDataCollector dataCollector, MethodRuleDefinition<R> ruleDefinition, ModelType<S> expectedDependency) {
    // TODO:DAZ Use ModelType.toString instead of getSimpleName()
    List<ModelReference<?>> references = ruleDefinition.getReferences();
    ModelType<? extends S> dependency = null;
    for (ModelReference<?> reference : references) {
        ModelType<? extends S> newDependency = expectedDependency.asSubclass(reference.getType());
        if (newDependency != null) {
            if (dependency != null) {
                throw new InvalidComponentModelException(String.format("%s method must have one parameter extending %s. Found multiple parameter extending %s.", annotationType.getSimpleName(),
                        expectedDependency.getConcreteClass().getSimpleName(),
                        expectedDependency.getConcreteClass().getSimpleName()));

            }
            dependency = newDependency;
        }
    }

    if (dependency == null) {
        throw new InvalidComponentModelException(String.format("%s method must have one parameter extending %s. Found no parameter extending %s.", annotationType.getSimpleName(),
                expectedDependency.getConcreteClass().getSimpleName(),
                expectedDependency.getConcreteClass().getSimpleName()));
    }
    dataCollector.put(expectedDependency.getConcreteClass(), dependency.getConcreteClass());
}
 
開發者ID:Pushjet,項目名稱:Pushjet-Android,代碼行數:25,代碼來源:AbstractAnnotationDrivenMethodComponentRuleDefinitionHandler.java

示例6: apply

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(LanguageBasePlugin.class);

    LanguageRegistry languageRegistry = project.getExtensions().create("languages", DefaultLanguageRegistry.class);
    ProjectSourceSet sources = project.getExtensions().getByType(ProjectSourceSet.class);

    DefaultComponentSpecContainer components = project.getExtensions().create("componentSpecs", DefaultComponentSpecContainer.class, instantiator);
    modelRegistry.create(
            ModelCreators.of(ModelReference.of("componentSpecs", DefaultComponentSpecContainer.class), components)
                    .simpleDescriptor("Project.<init>.componentSpecs()")
                    .withProjection(new PolymorphicDomainObjectContainerModelProjection<DefaultComponentSpecContainer, ComponentSpec>(components, ComponentSpec.class))
                    .build()
                    );

    // TODO:DAZ Convert to model rules
    createLanguageSourceSets(sources, components, languageRegistry, project.getFileResolver());
}
 
開發者ID:Pushjet,項目名稱:Pushjet-Android,代碼行數:18,代碼來源:ComponentModelBasePlugin.java

示例7: toInputBuilder

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
private UnboundRuleInput.Builder toInputBuilder(ModelBinding<?> binding, ModelReference<?> reference) {
    UnboundRuleInput.Builder builder = UnboundRuleInput.type(reference.getType());
    ModelPath path;
    if (binding != null) {
        builder.bound();
        path = binding.getPath();
    } else {
        path = reference.getPath();
        if (path != null) {
            builder.suggestions(CollectionUtils.stringize(suggestionsProvider.transform(path)));
        }
    }
    if (path != null) {
        builder.path(path);
    }
    builder.description(reference.getDescription());
    return builder;
}
 
開發者ID:Pushjet,項目名稱:Pushjet-Android,代碼行數:19,代碼來源:UnboundRulesProcessor.java

示例8: registerConfigurationAction

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
private void registerConfigurationAction(final Closure<?> action) {
    modelRegistry.mutate(new ModelMutator<Object>() {
        public ModelReference<Object> getSubject() {
            return ModelReference.untyped(modelPath);
        }

        public void mutate(Object object, Inputs inputs) {
            new ClosureBackedAction<Object>(action).execute(object);
        }

        public ModelRuleDescriptor getDescriptor() {
            return new SimpleModelRuleDescriptor("model." + modelPath);
        }

        public List<ModelReference<?>> getInputs() {
            return Collections.emptyList();
        }
    });
}
 
開發者ID:Pushjet,項目名稱:Pushjet-Android,代碼行數:20,代碼來源:NonTransformedModelDslBacking.java

示例9: registration

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
@Nullable
@Override
public <R, S> ExtractedModelRule registration(MethodRuleDefinition<R, S> ruleDefinition, MethodModelRuleExtractionContext context) {
    validateIsVoidMethod(ruleDefinition, context);

    if (ruleDefinition.getReferences().size() != 1) {
        context.add(ruleDefinition, String.format("A method %s must have a single parameter of type %s.", getDescription(), TypeBuilder.class.getName()));
        return null;
    }

    ModelReference<?> subjectReference = ruleDefinition.getSubjectReference();
    ModelType<?> subjectType = subjectReference.getType();
    Class<?> rawSubjectType = subjectType.getRawClass();
    if (!rawSubjectType.equals(TypeBuilder.class)) {
        context.add(ruleDefinition, String.format("A method %s must have a single parameter of type %s.", getDescription(), TypeBuilder.class.getName()));
        return null;
    }

    List<ModelType<?>> typeVariables = subjectType.getTypeVariables();
    if (typeVariables.size() != 1) {
        context.add(ruleDefinition, String.format("Parameter of type %s must declare a type parameter.", rawSubjectType.getName()));
        return null;
    }

    ModelType<?> builtType = typeVariables.get(0);
    if (builtType.isWildcard()) {
        context.add(ruleDefinition, String.format("Type '%s' cannot be a wildcard type (i.e. cannot use ? super, ? extends etc.).", builtType.toString()));
        return null;
    }

    ComponentTypeRegistrationInfo info = componentTypeRegistrationInfoFor(builtType);
    if (info == null) {
        context.add(ruleDefinition, String.format("Type '%s' is not a subtype of '%s'.", builtType.toString(), COMPONENT_SPEC_MODEL_TYPE.toString()));
        return null;
    }

    return new ExtractedTypeRule(ruleDefinition, info, builtType.asSubtype(info.baseInterface));
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:39,代碼來源:ComponentTypeModelRuleExtractor.java

示例10: visitDependency

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
protected <S> void visitDependency(RuleMethodDataCollector dataCollector, MethodRuleDefinition<?, ?> ruleDefinition, ModelType<S> expectedDependency, RuleSourceValidationProblemCollector problems) {
    if (ruleDefinition.getReferences().isEmpty() && problems.hasProblems()) {
        return;
    }

    List<ModelReference<?>> references = ruleDefinition.getReferences();
    ModelType<? extends S> dependency = null;
    for (ModelReference<?> reference : references) {
        if (expectedDependency.isAssignableFrom(reference.getType())) {
            if (dependency != null) {
                problems.add(ruleDefinition, String.format("A method %s must have one parameter extending %s. Found multiple parameter extending %s.", getDescription(),
                                            expectedDependency.getDisplayName(),
                                            expectedDependency.getDisplayName()));
                return;
            }
            dependency = reference.getType().asSubtype(expectedDependency);
        }
    }

    if (dependency == null) {
        problems.add(ruleDefinition, String.format("A method %s must have one parameter extending %s. Found no parameter extending %s.", getDescription(),
                expectedDependency.getDisplayName(),
                expectedDependency.getDisplayName()));
        return;
    }
    dataCollector.put(expectedDependency, dependency);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:28,代碼來源:AbstractAnnotationDrivenComponentModelRuleExtractor.java

示例11: ModelMapBasedRule

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
public ModelMapBasedRule(ModelReference<C> subject, final ModelType<? extends T> baseType, MethodRuleDefinition<?, ?> ruleDefinition, ModelReference<?>... additionalInputs) {
    super(subject, ruleDefinition.getDescriptor());
    this.inputs = calculateInputs(
            baseType,
            ruleDefinition.getReferences().subList(1, ruleDefinition.getReferences().size()),
            Arrays.asList(additionalInputs)
    );
    this.baseTypeParameterIndex = 1 + Iterables.indexOf(ruleDefinition.getReferences().subList(1, ruleDefinition.getReferences().size()), new Predicate<ModelReference<?>>() {
        @Override
        public boolean apply(ModelReference<?> element) {
            return element.getType().equals(baseType);
        }
    });
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:15,代碼來源:ModelMapBasedRule.java

示例12: calculateInputs

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
private static ImmutableList<ModelReference<?>> calculateInputs(final ModelType<?> baseType, final List<ModelReference<?>> references, List<ModelReference<?>> modelReferences) {
    Iterable<ModelReference<?>> filteredReferences = Iterables.filter(references, new Predicate<ModelReference<?>>() {
        @Override
        public boolean apply(ModelReference<?> element) {
            return !element.getType().equals(baseType);
        }
    });

    ImmutableList.Builder<ModelReference<?>> allInputs = ImmutableList.builder();
    allInputs.addAll(modelReferences);
    allInputs.addAll(filteredReferences);
    return allInputs.build();
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:14,代碼來源:ModelMapBasedRule.java

示例13: apply

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
@Override
public void apply(final MethodModelRuleApplicationContext context, MutableModelNode target) {
    MethodRuleDefinition<?, ?> ruleDefinition = getRuleDefinition();
    ModelReference<?> targetReference = ruleDefinition.getReferences().get(1);
    List<ModelReference<?>> inputs = ruleDefinition.getReferences().subList(2, ruleDefinition.getReferences().size());
    RuleSourceApplicationAction ruleAction = new RuleSourceApplicationAction(targetReference, ruleDefinition.getDescriptor(), inputs, ruleSourceType, ruleExtractor);
    RuleExtractorUtils.configureRuleAction(context, ruleApplicationScope, ModelActionRole.Defaults, ruleAction);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:9,代碼來源:RuleDefinitionRuleExtractor.java

示例14: RuleSourceApplicationAction

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
public RuleSourceApplicationAction(ModelReference<?> targetReference, ModelRuleDescriptor descriptor, List<ModelReference<?>> inputs, ModelType<? extends RuleSource> ruleSourceType, ModelRuleExtractor ruleExtractor) {
    this.targetReference = targetReference;
    this.descriptor = descriptor;
    this.inputs = inputs;
    this.ruleSourceType = ruleSourceType;
    this.ruleExtractor = ruleExtractor;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:8,代碼來源:RuleDefinitionRuleExtractor.java

示例15: validateRuleMethod

import org.gradle.model.internal.core.ModelReference; //導入依賴的package包/類
private void validateRuleMethod(MethodRuleDefinition<?, ?> ruleDefinition, Method ruleMethod, RuleSourceValidationProblemCollector problems) {
    if (Modifier.isPrivate(ruleMethod.getModifiers())) {
        problems.add(ruleMethod, "A rule method cannot be private");
    }
    if (Modifier.isAbstract(ruleMethod.getModifiers())) {
        problems.add(ruleMethod, "A rule method cannot be abstract");
    }

    if (ruleMethod.getTypeParameters().length > 0) {
        problems.add(ruleMethod, "Cannot have type variables (i.e. cannot be a generic method)");
    }

    // TODO validations on method: synthetic, bridge methods, varargs, abstract, native
    ModelType<?> returnType = ModelType.returnType(ruleMethod);
    if (returnType.isRawClassOfParameterizedType()) {
        problems.add(ruleMethod, "Raw type " + returnType + " used for return type (all type parameters must be specified of parameterized type)");
    }

    for (int i = 0; i < ruleDefinition.getReferences().size(); i++) {
        ModelReference<?> reference = ruleDefinition.getReferences().get(i);
        if (reference.getType().isRawClassOfParameterizedType()) {
            problems.add(ruleMethod, "Raw type " + reference.getType() + " used for parameter " + (i + 1) + " (all type parameters must be specified of parameterized type)");
        }
        if (reference.getPath() != null) {
            try {
                ModelPath.validatePath(reference.getPath().getPath());
            } catch (Exception e) {
                problems.add(ruleDefinition, "The declared model element path '" + reference.getPath().getPath() + "' used for parameter " + (i + 1) + " is not a valid path", e);
            }
        }
    }
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:33,代碼來源:ModelRuleExtractor.java


注:本文中的org.gradle.model.internal.core.ModelReference類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。