本文整理汇总了Java中org.codehaus.groovy.runtime.DefaultGroovyMethods.asType方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultGroovyMethods.asType方法的具体用法?Java DefaultGroovyMethods.asType怎么用?Java DefaultGroovyMethods.asType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.runtime.DefaultGroovyMethods
的用法示例。
在下文中一共展示了DefaultGroovyMethods.asType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBuilderAfterEvaluate
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
public void createBuilderAfterEvaluate() throws Exception {
AndroidBuilder androidBuilder = appPluginHook.getAndroidBuilder();
if (null == androidBuilder) {
return;
}
AndroidBuilder atlasBuilder = new AtlasBuilder(project.equals(project.getRootProject()) ? project
.getName() : project.getPath(),
creator,
new GradleProcessExecutor(project),
new GradleJavaProcessExecutor(project),
DefaultGroovyMethods.asType(ReflectUtils.getField(
androidBuilder,
"mErrorReporter"),
ErrorReporter.class),
LoggerWrapper.getLogger(AtlasBuilder.class),
DefaultGroovyMethods.asType(ReflectUtils.getField(
androidBuilder,
"mVerboseExec"), Boolean.class));
((AtlasBuilder) atlasBuilder).setDefaultBuilder(androidBuilder);
((AtlasBuilder) atlasBuilder).setAtlasExtension(atlasExtension);
AtlasBuildContext.androidBuilderMap.put(project, (AtlasBuilder) (atlasBuilder));
}
示例2: configTasksAfterEvaluate
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
public void configTasksAfterEvaluate() {
if (PluginTypeUtils.isAppProject(project)) {
AppExtension appExtension = DefaultGroovyMethods.asType(DefaultGroovyMethods.getAt(
project.getExtensions(),
"android"), AppExtension.class);
new AtlasAppTaskManager(AtlasBuildContext.androidBuilderMap.get(project),
appExtension,
project,
atlasExtension).run();
} else if (PluginTypeUtils.isLibraryProject(project)) {
LibraryExtension libExtension = DefaultGroovyMethods.asType(DefaultGroovyMethods.getAt(
project.getExtensions(),
"android"), LibraryExtension.class);
new AtlasLibTaskManager(AtlasBuildContext.androidBuilderMap.get(project),
libExtension,
project,
atlasExtension).run();
}
}
示例3: getElementPredicate
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
@NotNull
@Override
protected PsiElementPredicate getElementPredicate() {
return new PsiElementPredicate() {
@Override
public boolean satisfiedBy(PsiElement element) {
if (!element.getNode().getElementType().equals(GroovyTokenTypes.kIF)) return false;
if (!(element.getParent() instanceof GrIfStatement)) return false;
final GrIfStatement ifStatement = DefaultGroovyMethods.asType(element.getParent(), GrIfStatement.class);
final GrIfStatement elseIf = getElseIf(ifStatement);
return elseIf != null && checkIf(ifStatement) && checkIf(elseIf);
}
};
}
示例4: getElementPredicate
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
@NotNull
@Override
protected PsiElementPredicate getElementPredicate() {
return new PsiElementPredicate() {
@Override
public boolean satisfiedBy(PsiElement element) {
PsiElement parent = element.getParent();
if (parent instanceof GrArgumentLabel &&
((GrArgumentLabel)parent).getNameElement().equals(element) &&
parent.getParent() != null &&
parent.getParent().getParent() instanceof GrListOrMap) {
GrListOrMap map = DefaultGroovyMethods.asType(parent.getParent().getParent(), GrListOrMap.class);
if (!ErrorUtil.containsError(map) && map.getInitializers().length == 0 && isLiteralKeys(map.getNamedArguments())) {
return true;
}
}
return false;
}
};
}
示例5: configDexPatchTasksAfterEvaluate
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
public void configDexPatchTasksAfterEvaluate() {
if (PluginTypeUtils.isAppProject(project)) {
AppExtension appExtension = DefaultGroovyMethods.asType(DefaultGroovyMethods.getAt(
project.getExtensions(),
"android"), AppExtension.class);
new DexPatchTaskManager(AtlasBuildContext.androidBuilderMap.get(project),
appExtension,
project,
atlasExtension).run();
}
}
示例6: processIntention
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
@Override
protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
final GrIfStatement ifStatement = DefaultGroovyMethods.asType(element.getParent(), GrIfStatement.class);
final GrIfStatement elseIf = getElseIf(ifStatement);
final GrIfStatement elseIfCopy = DefaultGroovyMethods.asType(elseIf.copy(), GrIfStatement.class);
elseIf.getCondition().replaceWithExpression(ifStatement.getCondition(), true);
elseIf.getThenBranch().replaceWithStatement(ifStatement.getThenBranch());
ifStatement.getCondition().replaceWithExpression(elseIfCopy.getCondition(), true);
ifStatement.getThenBranch().replaceWithStatement(elseIfCopy.getThenBranch());
}
示例7: getElseIf
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
private static GrIfStatement getElseIf(GrIfStatement ifStatement) {
final GrStatement elseBranch = ifStatement.getElseBranch();
if (elseBranch == null) return null;
if (elseBranch instanceof GrIfStatement) {
return DefaultGroovyMethods.asType(elseBranch, GrIfStatement.class);
}
else {
return null;
}
}
示例8: invoke
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull final Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
if (elements.length != 1) return;
myProject = project;
PsiElement element = elements[0];
GrTypeDefinition aClass;
PsiElement aMember = null;
if (element instanceof GrTypeDefinition) {
aClass = (GrTypeDefinition)element;
}
else if (element instanceof GrMethod) {
aClass = DefaultGroovyMethods.asType(((GrMethod)element).getContainingClass(), GrTypeDefinition.class);
aMember = element;
}
else if (element instanceof GrField) {
aClass = DefaultGroovyMethods.asType(((GrField)element).getContainingClass(), GrTypeDefinition.class);
aMember = element;
}
else {
return;
}
invokeImpl(project, dataContext, aClass, aMember);
}
示例9: getBooleanAnnotationParameter
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
protected static boolean getBooleanAnnotationParameter(AnnotationNode node, String parameterName, boolean defaultValue) {
Expression member = node.getMember(parameterName);
if (member != null) {
if (member instanceof ConstantExpression) {
try {
return DefaultGroovyMethods.asType(((ConstantExpression) member).getValue(), Boolean.class);
} catch (Exception e) {
internalError("Expecting boolean value for " + parameterName + " annotation parameter. Found " + member + "member");
}
} else {
internalError("Expecting boolean value for " + parameterName + " annotation parameter. Found " + member + "member");
}
}
return defaultValue;
}
示例10: convertConstant
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
private static Object convertConstant(Number source, ClassNode target) {
if (ClassHelper.Byte_TYPE.equals(target)) {
return source.byteValue();
}
if (ClassHelper.Short_TYPE.equals(target)) {
return source.shortValue();
}
if (ClassHelper.Integer_TYPE.equals(target)) {
return source.intValue();
}
if (ClassHelper.Long_TYPE.equals(target)) {
return source.longValue();
}
if (ClassHelper.Float_TYPE.equals(target)) {
return source.floatValue();
}
if (ClassHelper.Double_TYPE.equals(target)) {
return source.doubleValue();
}
if (ClassHelper.BigInteger_TYPE.equals(target)) {
return DefaultGroovyMethods.asType(source, BigInteger.class);
}
if (ClassHelper.BigDecimal_TYPE.equals(target)) {
return DefaultGroovyMethods.asType(source, BigDecimal.class);
}
throw new IllegalArgumentException("Unsupported conversion");
}
示例11: getAsType
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
/**
* Converts a class implementing some trait into a target class. If the trait is a dynamic proxy and
* that the target class is assignable to the target object of the proxy, then the target object is
* returned. Otherwise, falls back to {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#asType(java.lang.Object, Class)}
* @param self an object to be coerced to some class
* @param clazz the class to be coerced to
* @return the object coerced to the target class, or the proxy instance if it is compatible with the target class.
*/
@SuppressWarnings("unchecked")
public static <T> T getAsType(Object self, Class<T> clazz) {
if (self instanceof GeneratedGroovyProxy) {
Object proxyTarget = ((GeneratedGroovyProxy)self).getProxyTarget();
if (clazz.isAssignableFrom(proxyTarget.getClass())) {
return (T) proxyTarget;
}
}
return DefaultGroovyMethods.asType(self, clazz);
}
示例12: testImport
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
@Test
public void testImport() {
VistaDataChunk chunk = MockVistaDataChunks.createFromJson(getAllergyResourceAsStream(), mockPatient, "allergy");
Allergy a = (Allergy) importer.convert(chunk);
assertThat(a.getPid(), is(equalTo(MOCK_PID)));
assertThat(a.getFacilityCode(), is(equalTo("500")));
assertThat(a.getFacilityName(), is(equalTo("CAMP MASTER")));
assertThat(a.getUid(), is(equalTo(UidUtils.getAllergyUid(MockVistaDataChunks.VISTA_ID, "100846", "982"))));
assertThat(a.getLocalId(), is(equalTo("982")));
assertThat(a.getMechanism(), is(equalTo("DRUG OTHER")));
assertThat(a.getEntered(), is(new PointInTime(2011, 11, 22, 13, 43)));
assertThat(a.getVerified(), is(new PointInTime(2011, 11, 22, 13, 43, 43)));
assertThat(a.getSeverityName(), is(nullValue()));
assertThat(a.getSeverityCode(), is(nullValue()));
assertThat(a.getHistorical(), is(true));
assertThat(a.getReference(), is(equalTo("219;PSNDF(50.6,")));
assertThat(a.getProducts().size(), equalTo(1));
AllergyProduct p = DefaultGroovyMethods.asType(DefaultGroovyMethods.toList(a.getProducts()).get(0), AllergyProduct.class);
assertThat(p.getName(), is(equalTo("DIPHENHYDRAMINE")));
assertThat(p.getVuid(), is(equalTo("urn:va:vuid:4019724")));
assertThat(p.getCode(), is(nullValue()));
Assert.assertEquals(1, a.getReactions().size());
AllergyReaction r = DefaultGroovyMethods.asType(DefaultGroovyMethods.toList(a.getReactions()).get(0), AllergyReaction.class);
Assert.assertEquals("ANXIETY", r.getName());
assertThat(r.getVuid(), is("urn:va:vuid:4637050"));
assertThat(r.getCode(), is(nullValue()));
}
示例13: getAt
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
public static Location getAt(World self, List pos){
Object p0 = DefaultGroovyMethods.getAt(pos, 0);
Object p1 = DefaultGroovyMethods.getAt(pos, 1);
Object p2 = DefaultGroovyMethods.getAt(pos, 2);
Double x = DefaultGroovyMethods.asType(p0, double.class);
Double y = DefaultGroovyMethods.asType(p1, double.class);
Double z = DefaultGroovyMethods.asType(p2, double.class);
return new Location(self, x, y, z);
}
示例14: showParameterInfo
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
@Override
public void showParameterInfo(@NotNull GrAnnotationArgumentList argumentList, @NotNull CreateParameterInfoContext context) {
final GrAnnotation parent = DefaultGroovyMethods.asType(argumentList.getParent(), GrAnnotation.class);
final PsiElement resolved = parent.getClassReference().resolve();
if (resolved instanceof PsiClass && ((PsiClass)resolved).isAnnotationType()) {
final PsiMethod[] methods = ((PsiClass)resolved).getMethods();
context.setItemsToShow(methods);
context.showHint(argumentList, argumentList.getTextRange().getStartOffset(), this);
final PsiAnnotationMethod currentMethod = findAnnotationMethod(context.getFile(), context.getEditor());
if (currentMethod != null) {
context.setHighlightedElement(currentMethod);
}
}
}
示例15: toFilter
import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
private PublishFilter toFilter(final Closure filter) {
return (PublishFilter) DefaultGroovyMethods.asType(filter, PublishFilter.class);
}