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


Java MirroredTypeException类代码示例

本文整理汇总了Java中javax.lang.model.type.MirroredTypeException的典型用法代码示例。如果您正苦于以下问题:Java MirroredTypeException类的具体用法?Java MirroredTypeException怎么用?Java MirroredTypeException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: processElement

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
@Override
public void processElement(Element element) throws IOException
{
    //Get the @Component annotation for the current element.
    Component annot = element.getAnnotation(Component.class);
    String clsName = element.toString();
    String scope = "";
    try
    {
        annot.scope();
    }
    catch (MirroredTypeException e)
    {
        scope = e.getTypeMirror().toString();
    }
    appendProperty(clsName, scope);
}
 
开发者ID:touwolf,项目名称:bridje-framework,代码行数:18,代码来源:ComponentProcessor.java

示例2: parseRClass

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
private void parseRClass(String respectivePackageName, String rClass) {
  Element element;

  try {
    element = elementUtils.getTypeElement(rClass);
  } catch (MirroredTypeException mte) {
    element = typeUtils.asElement(mte.getTypeMirror());
  }

  JCTree tree = (JCTree) trees.getTree(element);
  if (tree != null) { // tree can be null if the references are compiled types and not source
    IdScanner idScanner = new IdScanner(symbols, elementUtils.getPackageOf(element)
        .getQualifiedName().toString(), respectivePackageName);
    tree.accept(idScanner);
  } else {
    parseCompiledR(respectivePackageName, (TypeElement) element);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:ButterKnifeProcessor.java

示例3: getViewClassFromAnnotationParams

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
private String getViewClassFromAnnotationParams(TypeElement typeElement) {
	InjectViewState annotation = typeElement.getAnnotation(InjectViewState.class);
	String mvpViewClassName = "";

	if (annotation != null) {
		TypeMirror value = null;
		try {
			annotation.view();
		} catch (MirroredTypeException mte) {
			value = mte.getTypeMirror();
		}

		mvpViewClassName = Util.getFullClassName(value);
	}

	if (mvpViewClassName.isEmpty() || DefaultView.class.getName().equals(mvpViewClassName)) {
		return null;
	}

	return mvpViewClassName;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:ViewStateProviderClassGenerator.java

示例4: getViewStateClassFromAnnotationParams

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
private String getViewStateClassFromAnnotationParams(TypeElement typeElement) {
	InjectViewState annotation = typeElement.getAnnotation(InjectViewState.class);
	String mvpViewStateClassName = "";

	if (annotation != null) {
		TypeMirror value;
		try {
			annotation.value();
		} catch (MirroredTypeException mte) {
			value = mte.getTypeMirror();
			mvpViewStateClassName = value.toString();
		}
	}

	if (mvpViewStateClassName.isEmpty() || DefaultViewState.class.getName().equals(mvpViewStateClassName)) {
		return null;
	}

	return mvpViewStateClassName;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:ViewStateProviderClassGenerator.java

示例5: FactoryAnnotatedClass

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
public FactoryAnnotatedClass(TypeElement classElement) throws IllegalArgumentException {
    this.annotatedClassElement = classElement;
    Factory annotation = classElement.getAnnotation(Factory.class);
    id = annotation.id();

    if (id == null || id.length() == 0) {
        throw new IllegalArgumentException(
                String.format("id() in @%s for class %s is null or empty! that's not allowed",
                        Factory.class.getSimpleName(), classElement.getQualifiedName().toString()));
    }

    // Get the full QualifiedTypeName
    try {
        Class<?> clazz = annotation.type();
        qualifiedSuperClassName = clazz.getCanonicalName();
        simpleTypeName = clazz.getSimpleName();
    } catch (MirroredTypeException mte) {
        DeclaredType classTypeMirror = (DeclaredType) mte.getTypeMirror();
        TypeElement classTypeElement = (TypeElement) classTypeMirror.asElement();
        qualifiedSuperClassName = classTypeElement.getQualifiedName().toString();
        simpleTypeName = classTypeElement.getSimpleName().toString();
    }
}
 
开发者ID:jacklongway,项目名称:FactoryAnnotation,代码行数:24,代码来源:FactoryAnnotatedClass.java

示例6: JsonProperty

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
public JsonProperty(String humanName, ExecutableElement element) {
  this.methodName = element.getSimpleName().toString();
  this.humanName = humanName;
  this.element = element;
  this.type = TypeName.get(element.getReturnType());
  this.annotations = buildAnnotations(element);

  JsonAdapter jsonAdapter = element.getAnnotation(JsonAdapter.class);
  if (jsonAdapter != null) {
    try {
      jsonAdapter.value();
    } catch (MirroredTypeException e) {
      typeAdapter = e.getTypeMirror();
    }
  }

  DefaultValue defaultValue = element.getAnnotation(DefaultValue.class);
  if (defaultValue != null) {
    this.defaultValue = defaultValue.value();
  }
}
 
开发者ID:setheclark,项目名称:auto-value-json,代码行数:22,代码来源:JsonProperty.java

示例7: parseRClass

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
private void parseRClass(String respectivePackageName, String rClass) {
    Element element;

    try {
        element = elementUtils.getTypeElement(rClass);
    } catch (MirroredTypeException mte) {
        element = typeUtils.asElement(mte.getTypeMirror());
    }

    JCTree tree = (JCTree) trees.getTree(element);
    if (tree != null) {
        IdScanner idScanner = new IdScanner(symbols, elementUtils.getPackageOf(element)
                .getQualifiedName().toString(), respectivePackageName);
        tree.accept(idScanner);
    } else {
        parseCompiledR(respectivePackageName, (TypeElement) element);
    }
}
 
开发者ID:WellingtonCosta,项目名称:convalida,代码行数:19,代码来源:ConvalidaProcessor.java

示例8: Property

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
Property(String fieldName, TypeName typeName, VariableElement element, boolean isMapped) {
    this.fieldName = fieldName;
    this.element = element;
    this.typeName = typeName;
    this.annotations = getAnnotations(element);
    this.isMapped = isMapped;

    // get the parcel adapter if any
    ParcelAdapter parcelAdapter = element.getAnnotation(ParcelAdapter.class);
    if (parcelAdapter != null) {
        try {
            parcelAdapter.value();
        } catch (MirroredTypeException e) {
            this.typeAdapter = e.getTypeMirror();
        }
    }

    // get the element version, default 0
    ParcelVersion parcelVersion = element.getAnnotation(ParcelVersion.class);
    this.version = parcelVersion == null ? 0 : parcelVersion.from();
}
 
开发者ID:foodora,项目名称:android-auto-mapper,代码行数:22,代码来源:AutoMappperProcessor.java

示例9: FactoryAnnotatedClass

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
public FactoryAnnotatedClass(TypeElement classElement) throws IllegalArgumentException {
    this.annotatedClassElement = classElement;
    Factory annotation = classElement.getAnnotation(Factory.class);
    id = annotation.id();

    if ("".equalsIgnoreCase(id) || id == null) {
        throw new IllegalArgumentException(
                String.format("id() in @%s for class %s is null or empty! that's not allowed",
                        Factory.class.getSimpleName(), classElement.getQualifiedName().toString()));
    }

    // Get the full QualifiedTypeName
    try {
        Class<?> clazz = annotation.type();
        // 返回底层阶级Java语言规范中定义的标准名称。
        qualifiedSuperClassName = clazz.getCanonicalName();
        simpleTypeName = clazz.getSimpleName();
    } catch (MirroredTypeException mte) {
        DeclaredType classTypeMirror = (DeclaredType) mte.getTypeMirror();
        TypeElement classTypeElement = (TypeElement) classTypeMirror.asElement();
        qualifiedSuperClassName = classTypeElement.getQualifiedName().toString();
        simpleTypeName = classTypeElement.getSimpleName().toString();
    }
}
 
开发者ID:CharonChui,项目名称:AnnotationDemo,代码行数:25,代码来源:FactoryAnnotatedClass.java

示例10: getConvertClass

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
private TypeName getConvertClass(PrefField prefField) {
    TypeElement typeElement = null;
    try {
        prefField.converter();
    } catch (MirroredTypeException e) {
        DeclaredType typeMirror = (DeclaredType) e.getTypeMirror();
        typeElement = (TypeElement) typeMirror.asElement();
    }
    if (typeElement == null) {
        throw new IllegalArgumentException("TypeConverter may be wrong");
    }

    TypeMirror superType = typeElement.getSuperclass();
    TypeMirror arg = ((DeclaredType) superType).getTypeArguments().get(1);
    return ClassName.get(arg);
}
 
开发者ID:kobakei,项目名称:spot,代码行数:17,代码来源:SpotCompiler.java

示例11: parseRClass

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
private void parseRClass(String rClass) {
  Element element;

  try {
    element = elementUtils.getTypeElement(rClass);
  } catch (MirroredTypeException mte) {
    element = typeUtils.asElement(mte.getTypeMirror());
  }

  JCTree tree = (JCTree) trees.getTree(element);
  if (tree != null) { // tree can be null if the references are compiled types and not source
    IdScanner idScanner =
        new IdScanner(symbols, elementUtils.getPackageOf(element).getQualifiedName().toString());
    tree.accept(idScanner);
  } else {
    parseCompiledR((TypeElement) element);
  }
}
 
开发者ID:hoangkien0705,项目名称:Android-ButterKinfe,代码行数:19,代码来源:ButterKnifeProcessor.java

示例12: parseConductorController

import javax.lang.model.type.MirroredTypeException; //导入依赖的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

示例13: SPResponse

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
public SPResponse(ApiResponse apiResponse, ExecutableElement element) {
    int intCode = apiResponse.code();
    if (intCode != -1) {
        code = String.valueOf(apiResponse.code());
    } else {
        code = "default";
    }
    description = apiResponse.message();

    TypeMirror tm = null;
    try {
        // Force exception
        apiResponse.response().toString();
    } catch (MirroredTypeException e) {
        tm = e.getTypeMirror();
    }

    schema = SPSchema.fromTypeMirrorAndContainer(tm, apiResponse.responseContainer(), element);
}
 
开发者ID:AlbertoSH,项目名称:Swagplash,代码行数:20,代码来源:SPResponse.java

示例14: getBehaviourMockery

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
private Mockery.Behaviour getBehaviourMockery(Mockery mockery) {
  try {
    mockery.value();
  } catch (MirroredTypeException e) {
    TypeElement typeElement = (TypeElement) types.asElement(e.getTypeMirror());
    try {
      String className = typeElement.getQualifiedName().toString();
      Class<?> behaviourClass = Class.forName(className);
      Mockery.Behaviour behaviour = (Mockery.Behaviour) instantiateInterface.from(behaviourClass);
      return behaviour;
    } catch (ClassNotFoundException e1) {
      e1.printStackTrace();
    }
  }
  return null;
}
 
开发者ID:VictorAlbertos,项目名称:Mockery,代码行数:17,代码来源:GetTestClass.java

示例15: Property

import javax.lang.model.type.MirroredTypeException; //导入依赖的package包/类
Property(String fieldName, VariableElement element) {
    this.fieldName = fieldName;
    this.element = element;
    this.typeName = TypeName.get(element.asType());
    this.annotations = getAnnotations(element);

    // get the parcel adapter if any
    ParcelAdapter parcelAdapter = element.getAnnotation(ParcelAdapter.class);
    if (parcelAdapter != null) {
        try {
            parcelAdapter.value();
        } catch (MirroredTypeException e) {
            this.typeAdapter = e.getTypeMirror();
        }
    }

    // get the element version, default 0
    ParcelVersion parcelVersion = element.getAnnotation(ParcelVersion.class);
    this.version = parcelVersion == null ? 0 : parcelVersion.from();
}
 
开发者ID:aitorvs,项目名称:auto-parcel,代码行数:21,代码来源:AutoParcelProcessor.java


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