本文整理汇总了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);
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
示例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();
}
示例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();
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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();
}