本文整理匯總了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();
}