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


Java SuperficialValidation.validateElement方法代码示例

本文整理汇总了Java中com.google.auto.common.SuperficialValidation.validateElement方法的典型用法代码示例。如果您正苦于以下问题:Java SuperficialValidation.validateElement方法的具体用法?Java SuperficialValidation.validateElement怎么用?Java SuperficialValidation.validateElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.auto.common.SuperficialValidation的用法示例。


在下文中一共展示了SuperficialValidation.validateElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findAndParseListener

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private void findAndParseListener(RoundEnvironment env,
    Class<? extends Annotation> annotationClass,
    Map<TypeElement, BindingSet.Builder> builderMap, Set<TypeElement> erasedTargetNames) {
  for (Element element : env.getElementsAnnotatedWith(annotationClass)) {
    if (!SuperficialValidation.validateElement(element)) continue;
    try {
      parseListenerAnnotation(annotationClass, element, builderMap, erasedTargetNames);
    } catch (Exception e) {
      StringWriter stackTrace = new StringWriter();
      e.printStackTrace(new PrintWriter(stackTrace));

      error(element, "Unable to generate view binder for @%s.\n\n%s",
          annotationClass.getSimpleName(), stackTrace.toString());
    }
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:ButterKnifeProcessor.java

示例2: parsePresenterInjection

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private void parsePresenterInjection(Element element,
                                     Map<TypeElement, DelegateClassGenerator> delegateClassMap) {
    //TODO print errors
    if (!SuperficialValidation.validateElement(element)) {
        error("Superficial validation error for %s", element.getSimpleName());
        return;
    }
    if (Validator.isPrivate(element)) {
        error("%s can't be private", element.getSimpleName());
        return;
    }
    VariableElement variableElement = (VariableElement) element;
    DelegateClassGenerator delegateClassGenerator =
            getDelegate((TypeElement) element.getEnclosingElement(),
                        delegateClassMap);
    delegateClassGenerator.setViewPresenterField(variableElement.getSimpleName().toString());
    if (variableElement.getAnnotation(Inject.class) != null) {
        delegateClassGenerator.injectablePresenterInView(true);
    }
    delegateClassGenerator.setPresenterTypeInView(variableElement.asType().toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:EasyMVPProcessor.java

示例3: findAndParseListener

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private void findAndParseListener(RoundEnvironment env,
    Class<? extends Annotation> annotationClass, Map<TypeElement, BindingClass> targetClassMap,
    Set<TypeElement> erasedTargetNames) {
  for (Element element : env.getElementsAnnotatedWith(annotationClass)) {
    if (!SuperficialValidation.validateElement(element)) continue;
    try {
      parseListenerAnnotation(annotationClass, element, targetClassMap, erasedTargetNames);
    } catch (Exception e) {
      StringWriter stackTrace = new StringWriter();
      e.printStackTrace(new PrintWriter(stackTrace));

      error(element, "Unable to generate view binder for @%s.\n\n%s",
          annotationClass.getSimpleName(), stackTrace.toString());
    }
  }
}
 
开发者ID:hoangkien0705,项目名称:Android-ButterKinfe,代码行数:17,代码来源:ButterKnifeProcessor.java

示例4: parseConductorController

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private void parseConductorController(Element element,
                                      Map<TypeElement, DelegateClassGenerator> delegateClassMap) {
    if (!SuperficialValidation.validateElement(element)) {
        error("Superficial validation error for %s", element.getSimpleName());
        return;
    }
    if (!Validator.isNotAbstractClass(element)) {
        error("%s is abstract", element.getSimpleName());
        return;
    }
    if (!Validator.isSubType(element, CONDUCTOR_CONTROLLER_CLASS_NAME, processingEnv)) {
        error("%s must extend View", element.getSimpleName());
        return;
    }
    //getEnclosing for class type will returns its package/
    TypeElement enclosingElement = (TypeElement) element;
    DelegateClassGenerator delegateClassGenerator =
            getDelegate(enclosingElement, delegateClassMap);
    delegateClassGenerator.setViewType(ViewType.CONDUCTOR_CONTROLLER);
    ConductorController annotation = element.getAnnotation(ConductorController.class);
    try {
        annotation.presenter();
    } catch (MirroredTypeException mte) {
        parsePresenter(delegateClassGenerator, mte);
    }
}
 
开发者ID:6thsolution,项目名称:EasyMVP,代码行数:27,代码来源:EasyMVPProcessor.java

示例5: findAndParseTargets

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private Set<GeneratedType> findAndParseTargets(Set<Element> elements) {
    Set<GeneratedType> result = new LinkedHashSet<>();

    for (Element element : elements) {
        // Not too sure what this extra validation does, especially since it doesn't log what's wrong, but Wharton
        // has it in Butterknife.
        if (SuperficialValidation.validateElement(element) && validate(element)) {
            try {
                parse(element, result);
            } catch (Exception e) {
                logParsingError(element, getSupportedAnnotation(), e);
            }
        }
    }

    return result;
}
 
开发者ID:pijpijpij,项目名称:Noopetal,代码行数:18,代码来源:ClassGenerator.java

示例6: getTargetClsElement

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private TypeElement getTargetClsElement(Element element) {
    if (!SuperficialValidation.validateElement(element)) {
        return null;
    }
    if (element.getKind() != ElementKind.METHOD)  {
        error(element, "Annotation only supports applying to method");
        return null;
    }
    TypeElement targetClsElement = (TypeElement) element.getEnclosingElement();
    if (targetClsElement.getKind() != ElementKind.CLASS) {
        error(targetClsElement, "Parent element should be a class - %s", targetClsElement.getSimpleName());
        return null;
    }
    if (mDoneClassMap.containsKey(targetClsElement.getQualifiedName().toString())) {
        return null;
    }
    mDoneClassMap.put(targetClsElement.getQualifiedName().toString(), true);
    return targetClsElement;
}
 
开发者ID:Kudo,项目名称:RxRNBridge,代码行数:20,代码来源:RxRNBridgeProcessor.java

示例7: parseActivityView

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private void parseActivityView(Element element,
                               Map<TypeElement, DelegateClassGenerator> delegateClassMap) {
    //TODO print errors
    if (!SuperficialValidation.validateElement(element)) {
        error("Superficial validation error for %s", element.getSimpleName());
        return;
    }
    if (!Validator.isNotAbstractClass(element)) {
        error("%s is abstract", element.getSimpleName());
        return;
    }
    boolean isActivity =
            Validator.isSubType(element, ANDROID_ACTIVITY_CLASS_NAME, processingEnv);
    boolean isSupportActivity =
            Validator.isSubType(element, ANDROID_SUPPORT_ACTIVITY_CLASS_NAME, processingEnv);
    if (!isActivity && !isSupportActivity) {
        error("%s must extend Activity or AppCompatActivity", element.getSimpleName());
        return;
    }
    //getEnclosing for class type will returns its package/
    TypeElement enclosingElement = (TypeElement) element;
    DelegateClassGenerator delegateClassGenerator =
            getDelegate(enclosingElement, delegateClassMap);
    ActivityView annotation = element.getAnnotation(ActivityView.class);
    delegateClassGenerator.setResourceID(annotation.layout());
    if (isSupportActivity) {
        needSupportLoader = true;
        delegateClassGenerator.setViewType(ViewType.SUPPORT_ACTIVITY);
    } else {
        needLoader = true;
        delegateClassGenerator.setViewType(ViewType.ACTIVITY);
    }
    try {
        annotation.presenter();
    } catch (MirroredTypeException mte) {
        parsePresenter(delegateClassGenerator, mte);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:EasyMVPProcessor.java

示例8: parseFragmentView

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private void parseFragmentView(Element element,
                               Map<TypeElement, DelegateClassGenerator> delegateClassMap) {
    //TODO print errors
    if (!SuperficialValidation.validateElement(element)) {
        error("Superficial validation error for %s", element.getSimpleName());
        return;
    }
    if (!Validator.isNotAbstractClass(element)) {
        error("%s is abstract", element.getSimpleName());
        return;
    }
    boolean isFragment =
            Validator.isSubType(element, ANDROID_FRAGMENT_CLASS_NAME, processingEnv);
    boolean isSupportFragment =
            Validator.isSubType(element, ANDROID_SUPPORT_FRAGMENT_CLASS_NAME, processingEnv);
    if (!isFragment && !isSupportFragment) {
        error("%s must extend Fragment or support Fragment", element.getSimpleName());
        return;
    }
    //getEnclosing for class type will returns its package/
    TypeElement enclosingElement = (TypeElement) element;
    DelegateClassGenerator delegateClassGenerator =
            getDelegate(enclosingElement, delegateClassMap);
    if (isFragment) {
        needLoader = true;
        delegateClassGenerator.setViewType(ViewType.FRAGMENT);
    } else {
        needSupportLoader = true;
        delegateClassGenerator.setViewType(ViewType.SUPPORT_FRAGMENT);
    }
    FragmentView annotation = element.getAnnotation(FragmentView.class);
    try {
        annotation.presenter();
    } catch (MirroredTypeException mte) {
        parsePresenter(delegateClassGenerator, mte);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:EasyMVPProcessor.java

示例9: parseCustomView

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private void parseCustomView(Element element,
                             Map<TypeElement, DelegateClassGenerator> delegateClassMap) {
    //TODO print errors
    if (!SuperficialValidation.validateElement(element)) {
        error("Superficial validation error for %s", element.getSimpleName());
        return;
    }
    if (!Validator.isNotAbstractClass(element)) {
        error("%s is abstract", element.getSimpleName());
        return;
    }
    if (!Validator.isSubType(element, ANDROID_CUSTOM_VIEW_CLASS_NAME, processingEnv)) {
        error("%s must extend View", element.getSimpleName());
        return;
    }

    //getEnclosing for class type will returns its package/
    TypeElement enclosingElement = (TypeElement) element;
    DelegateClassGenerator delegateClassGenerator =
            getDelegate(enclosingElement, delegateClassMap);
    delegateClassGenerator.setViewType(ViewType.CUSTOM_VIEW);

    CustomView annotation = element.getAnnotation(CustomView.class);
    try {
        annotation.presenter();
    } catch (MirroredTypeException mte) {
        parsePresenter(delegateClassGenerator, mte);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:30,代码来源:EasyMVPProcessor.java

示例10: findAndParseTargets

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private List<JavaFile> findAndParseTargets(RoundEnvironment env) {
    List<JavaFile> javaFiles = new ArrayList<>();

    // Process each @RouterModule element.
    for (Element e : env.getElementsAnnotatedWith(RouterModule.class)) {
        if (!SuperficialValidation.validateElement(e))
            continue;
        List<? extends Element> allEle = e.getEnclosedElements();
        parseRouterModule(e, allEle, javaFiles);
    }
    return javaFiles;
}
 
开发者ID:TangXiaoLv,项目名称:Android-Router,代码行数:13,代码来源:AndroidRouterProcessor.java

示例11: validateInterface

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private boolean validateInterface(TypeMirror typeMirror) {
    TypeElement bindClassType = AnnotationUtils.getBindClassType(MoreTypes.asTypeElement(typeMirror), getProcessingEnv());
    if (bindClassType == null) {
        return true;
    }

    if (!SuperficialValidation.validateElement(bindClassType)) {
        return false;
    }

    return true;
}
 
开发者ID:trollsoftware,项目名称:jcomposition,代码行数:13,代码来源:GenerateStep.java

示例12: parseActivityView

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private void parseActivityView(Element element,
                               Map<TypeElement, DelegateClassGenerator> delegateClassMap) {
    //TODO print errors
    if (!SuperficialValidation.validateElement(element)) {
        error("Superficial validation error for %s", element.getSimpleName());
        return;
    }
    if (!Validator.isNotAbstractClass(element)) {
        error("%s is abstract", element.getSimpleName());
        return;
    }
    boolean isActivity =
            Validator.isSubType(element, ANDROID_ACTIVITY_CLASS_NAME, processingEnv);
    boolean isSupportActivity =
            Validator.isSubType(element, ANDROID_SUPPORT_ACTIVITY_CLASS_NAME, processingEnv);
    if (!isActivity && !isSupportActivity) {
        error("%s must extend Activity or AppCompatActivity", element.getSimpleName());
        return;
    }
    //getEnclosing for class type will returns its package/
    TypeElement enclosingElement = (TypeElement) element;
    DelegateClassGenerator delegateClassGenerator =
            getDelegate(enclosingElement, delegateClassMap);
    ActivityView annotation = element.getAnnotation(ActivityView.class);
    delegateClassGenerator.setResourceID(annotation.layout());
    if (isSupportActivity) {
        delegateClassGenerator.setViewType(ViewType.SUPPORT_ACTIVITY);
    } else {
        delegateClassGenerator.setViewType(ViewType.ACTIVITY);
    }
    try {
        annotation.presenter();
    } catch (MirroredTypeException mte) {
        parsePresenter(delegateClassGenerator, mte);
    }
}
 
开发者ID:6thsolution,项目名称:EasyMVP,代码行数:37,代码来源:EasyMVPProcessor.java

示例13: parseFragmentView

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private void parseFragmentView(Element element,
                               Map<TypeElement, DelegateClassGenerator> delegateClassMap) {
    //TODO print errors
    if (!SuperficialValidation.validateElement(element)) {
        error("Superficial validation error for %s", element.getSimpleName());
        return;
    }
    if (!Validator.isNotAbstractClass(element)) {
        error("%s is abstract", element.getSimpleName());
        return;
    }
    boolean isFragment =
            Validator.isSubType(element, ANDROID_FRAGMENT_CLASS_NAME, processingEnv);
    boolean isSupportFragment =
            Validator.isSubType(element, ANDROID_SUPPORT_FRAGMENT_CLASS_NAME, processingEnv);
    if (!isFragment && !isSupportFragment) {
        error("%s must extend Fragment or support Fragment", element.getSimpleName());
        return;
    }
    //getEnclosing for class type will returns its package/
    TypeElement enclosingElement = (TypeElement) element;
    DelegateClassGenerator delegateClassGenerator =
            getDelegate(enclosingElement, delegateClassMap);
    if (isFragment) {
        delegateClassGenerator.setViewType(ViewType.FRAGMENT);
    } else {
        delegateClassGenerator.setViewType(ViewType.SUPPORT_FRAGMENT);
    }
    FragmentView annotation = element.getAnnotation(FragmentView.class);
    try {
        annotation.presenter();
    } catch (MirroredTypeException mte) {
        parsePresenter(delegateClassGenerator, mte);
    }
}
 
开发者ID:6thsolution,项目名称:EasyMVP,代码行数:36,代码来源:EasyMVPProcessor.java

示例14: parsePresenterId

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private void parsePresenterId(Element element,
                              Map<TypeElement, DelegateClassGenerator> delegateClassMap) {
    if (!SuperficialValidation.validateElement(element)) {
        error("Superficial validation error for %s", element.getSimpleName());
        return;
    }
    if (Validator.isPrivate(element)) {
        error("%s can't be private", element.getSimpleName());
        return;
    }
    if (Validator.isMethod(element)) {
        ExecutableType emeth = (ExecutableType) element.asType();
        if (!emeth.getReturnType().getKind().equals(TypeKind.LONG) &&
                !emeth.getReturnType().getKind().equals(TypeKind.INT)) {
            error("%s must have return type int or long", element);
        }
    } else {
        TypeKind kind = element.asType().getKind();
        if (kind != TypeKind.INT && kind != TypeKind.LONG) {
            error("%s must be int or long", element.getSimpleName());
            return;
        }
    }
    String presenterId = element.toString();
    DelegateClassGenerator delegateClassGenerator =
            getDelegate((TypeElement) element.getEnclosingElement(),
                    delegateClassMap);
    delegateClassGenerator.setPresenterId(presenterId);
}
 
开发者ID:6thsolution,项目名称:EasyMVP,代码行数:30,代码来源:EasyMVPProcessor.java

示例15: findAndParseTargets

import com.google.auto.common.SuperficialValidation; //导入方法依赖的package包/类
private Map<TypeElement, CursonEntityClassGenerator> findAndParseTargets(RoundEnvironment env) {
    Map<TypeElement, CursonEntityClassGenerator> targetClassMap = new LinkedHashMap<>();
    Set<String> erasedTargetNames = new LinkedHashSet<>();

    // Process each @CursorRow element.
    for (Element element : env.getElementsAnnotatedWith(CursorRow.class)) {
        if (!SuperficialValidation.validateElement(element)) {
            continue;
        }
        parseBind(element, targetClassMap, erasedTargetNames);
    }
    return targetClassMap;
}
 
开发者ID:dkajiwara,项目名称:Curson,代码行数:14,代码来源:CursonProcessor.java


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