當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。