本文整理汇总了Java中com.google.auto.common.SuperficialValidation类的典型用法代码示例。如果您正苦于以下问题:Java SuperficialValidation类的具体用法?Java SuperficialValidation怎么用?Java SuperficialValidation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SuperficialValidation类属于com.google.auto.common包,在下文中一共展示了SuperficialValidation类的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());
}
}
}
示例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());
}
示例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());
}
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}