当前位置: 首页>>代码示例>>Java>>正文


Java DefaultGroovyMethods.asType方法代码示例

本文整理汇总了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));
    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:27,代码来源:AtlasConfigurationHelper.java

示例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();
        }
    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:21,代码来源:AtlasConfigurationHelper.java

示例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);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:FlipIfIntention.java

示例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;
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GrSortMapKeysIntention.java

示例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();
    }

}
 
开发者ID:alibaba,项目名称:atlas,代码行数:13,代码来源:AtlasConfigurationHelper.java

示例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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:FlipIfIntention.java

示例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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:FlipIfIntention.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:GrPullUpHandler.java

示例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;
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:AbstractInterruptibleASTTransformation.java

示例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");
}
 
开发者ID:apache,项目名称:groovy,代码行数:28,代码来源:BinaryExpressionTransformer.java

示例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);
}
 
开发者ID:apache,项目名称:groovy,代码行数:19,代码来源:Traits.java

示例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()));
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:34,代码来源:AllergyImporterTest.java

示例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);
}
 
开发者ID:DPOH-VAR,项目名称:VarScript,代码行数:10,代码来源:WorldExt.java

示例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);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:GroovyAnnotationAttributeInfoHandler.java

示例15: toFilter

import org.codehaus.groovy.runtime.DefaultGroovyMethods; //导入方法依赖的package包/类
private PublishFilter toFilter(final Closure filter) {
    return (PublishFilter) DefaultGroovyMethods.asType(filter, PublishFilter.class);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:4,代码来源:BasePomFilterContainer.java


注:本文中的org.codehaus.groovy.runtime.DefaultGroovyMethods.asType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。