當前位置: 首頁>>代碼示例>>Java>>正文


Java ElementKind.CLASS屬性代碼示例

本文整理匯總了Java中javax.lang.model.element.ElementKind.CLASS屬性的典型用法代碼示例。如果您正苦於以下問題:Java ElementKind.CLASS屬性的具體用法?Java ElementKind.CLASS怎麽用?Java ElementKind.CLASS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.lang.model.element.ElementKind的用法示例。


在下文中一共展示了ElementKind.CLASS屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processType

/**
 * 處理每一個TypeElement
 *
 * @param unitModels      保存DUnitModel
 * @param unitGroupModels 保存DUnitGroupModel
 * @param type            TypeElement
 */
private void processType(ArrayList<DUnitModel> unitModels, ArrayList<DUnitGroupModel> unitGroupModels, TypeElement type) {
	if (type.getKind() != ElementKind.CLASS) {
		mErrorReporter.abortWithError("@" + DUnit.class.getName() + " only applies to classes", type);
	}

	DUnit dUnit = type.getAnnotation(DUnit.class);
	DUnitGroup dUnitGroup = type.getAnnotation(DUnitGroup.class);

	if (dUnit != null) {
		DUnitModel unitModel = mUnitModelUtil.createUnitModel(type, dUnit);
		unitModels.add(unitModel);
	}

	if (dUnitGroup != null) {
		DUnitGroupModel unitGroupModel = mUnitModelUtil.createUnitGroupModel(type, dUnitGroup);
		unitGroupModels.add(unitGroupModel);
	}


}
 
開發者ID:tik5213,項目名稱:DUnit,代碼行數:27,代碼來源:DUnitProcessor.java

示例2: check

@Override
public WhiteListQuery.Result check(ElementHandle<?> element, WhiteListQuery.Operation operation) {
    if (!operation.equals(WhiteListQuery.Operation.USAGE)) {
        return OK;
    }
    List<WhiteListQuery.RuleDescription> rds = new ArrayList<WhiteListQuery.RuleDescription>();
    if (element.getKind() == ElementKind.CLASS || element.getKind() == ElementKind.INTERFACE) {
        String qn = element.getQualifiedName();
        if (qn.lastIndexOf('.') > 0) {
            String pack = qn.substring(0, qn.lastIndexOf("."));
            synchronized (IMPL_LOCK) {
                if (privatePackages.contains(pack)) {
                    rds.add(PRIVATE_RD);
                }
                if (transitivePackages.contains(pack)) {
                    rds.add(TRANSITIVE_RD);
                }
            }
            if (!rds.isEmpty()) {
                return new WhiteListQuery.Result(rds);
            }
        }
    }
    return OK;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:MavenWhiteListQueryImpl.java

示例3: getParentChain

private static String getParentChain(final TypeElement targetClass) {
	// if input is top level class return it
	// otherwise return the parent chain plus it

	if (targetClass.getNestingKind() == NestingKind.TOP_LEVEL) {
		return targetClass.getSimpleName().toString();
	} else {
		final Element parent = targetClass.getEnclosingElement();

		if (parent.getKind() != ElementKind.CLASS) {
			throw new RuntimeException("Cannot create parent chain. Non-class parent found.");
		}

		return (getParentChain((TypeElement) parent)) + "_" + targetClass.getSimpleName().toString();
	}
}
 
開發者ID:MatthewTamlin,項目名稱:Spyglass,代碼行數:16,代碼來源:CompanionNamer.java

示例4: collectConstructors

private void collectConstructors(Collection<IConstructor> constructors, Element element){
    if(element == null || element.getKind()!=ElementKind.CLASS) {
        return;
    }
    TypeElement el = (TypeElement) element;
    for(Element sub: el.getEnclosedElements()){
        if(sub.getKind() == ElementKind.CONSTRUCTOR){
            constructors.add(new Constructor(this, (ExecutableElement)sub));
        } else if ((sub.getKind() == ElementKind.CLASS) && (((TypeElement) sub).getSuperclass() != null)){
            TypeMirror supMirror = ((TypeElement) sub).getSuperclass();
            if (supMirror.getKind() == TypeKind.DECLARED) {
                DeclaredType superclassDeclaredType = (DeclaredType)supMirror;
                Element superclassElement = superclassDeclaredType.asElement();  
                collectConstructors(constructors, superclassElement);
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:Type.java

示例5: decodeKind

@NonNull
static ElementKind decodeKind (char kind) {
    switch (kind) {
        case EK_CLASS:
        case EK_LOCAL_CLASS:
            return ElementKind.CLASS;
        case EK_INTERFACE:
        case EK_LOCAL_INTERFACE:
            return ElementKind.INTERFACE;
        case EK_ENUM:
        case EK_LOCAL_ENUM:
            return ElementKind.ENUM;
        case EK_ANNOTATION:
        case EK_LOCAL_ANNOTATION:
            return ElementKind.ANNOTATION_TYPE;
        case EK_MODULE:
            return ElementKind.MODULE;
        default:
            throw new IllegalArgumentException ();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:DocumentUtil.java

示例6: process

@Override
public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnvironment) {
    TypeElement annotationElement = processingEnvironment.getElementUtils()
            .getTypeElement(ANNOTATION_CLASS);

    for (Element e : roundEnvironment.getElementsAnnotatedWith(annotationElement)) {
        if (e.getKind() == ElementKind.CLASS) {
            TypeElement te = (TypeElement) e;
            processClass(te);
        }
    }

    return true;
}
 
開發者ID:google,項目名稱:easybundler,代碼行數:14,代碼來源:BundlerClassProcessor.java

示例7: checkAbstractValueType

static boolean checkAbstractValueType(Element element, Collection<String> violations) {
  boolean ofSupportedKind = false
      || element.getKind() == ElementKind.INTERFACE
      || element.getKind() == ElementKind.ANNOTATION_TYPE
      || element.getKind() == ElementKind.CLASS;

  boolean staticOrTopLevel = false
      || element.getEnclosingElement().getKind() == ElementKind.PACKAGE
      || element.getModifiers().contains(Modifier.STATIC);

  boolean nonFinal = !element.getModifiers().contains(Modifier.FINAL);

  boolean publicOrPackageVisible =
      !element.getModifiers().contains(Modifier.PRIVATE)
          && !element.getModifiers().contains(Modifier.PROTECTED);

  if (!ofSupportedKind) {
    violations.add("must be class or interface or annotation type");
  }

  if (!nonFinal) {
    violations.add("must be non-final");
  }

  if (!publicOrPackageVisible) {
    violations.add("should be public or package-visible");
  }

  if (!staticOrTopLevel) {
    violations.add("should be top-level or static inner class");
  }

  return violations.isEmpty();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:34,代碼來源:ValueTypeComposer.java

示例8: isPossibleBuilderMethod

/**
 * Return true if the possibleBuilderMethod matches the
 * Style#attributeBuilder() and returns a class.
 *
 * TODO: may need to make this return true if the return type is an interface too...
 *
 * @param possibleBuilderMethod executableElement
 */
private static boolean isPossibleBuilderMethod(Element possibleBuilderMethod, boolean onValueType, ValueAttribute valueAttribute) {
  if (possibleBuilderMethod.getKind() == ElementKind.METHOD) {
    String detectedAttributeBuilder = valueAttribute.containingType.names()
        .rawFromAttributeBuilder(possibleBuilderMethod.getSimpleName().toString());

    if (detectedAttributeBuilder.isEmpty()) {
      return false;
    }
    ExecutableElement candidateMethod = (ExecutableElement) possibleBuilderMethod;

    return possibleBuilderMethod.getModifiers().containsAll(
        Arrays.asList(Modifier.STATIC, Modifier.PUBLIC))
        && candidateMethod.getParameters().isEmpty()
        && candidateMethod
        .getReturnType().getKind()
        == TypeKind.DECLARED
        && ((DeclaredType) candidateMethod.getReturnType())
        .asElement().getKind() == ElementKind.CLASS;

  } else if (!onValueType && possibleBuilderMethod.getKind() == ElementKind.CONSTRUCTOR) {
    if (!valueAttribute.containingType.names().newTokenInAttributeBuilder()) {
      return false;
    }

    ExecutableElement candidateConstructor = (ExecutableElement) possibleBuilderMethod;

    return candidateConstructor.getModifiers().contains(Modifier.PUBLIC)
        && candidateConstructor.getTypeParameters().isEmpty();
  }
  return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:39,代碼來源:AttributeBuilderReflection.java

示例9: isPossibleBuilderClass

/**
 * Determine if inner class could be a builder.
 *
 * @param possibleBuilderClass nested value element that could be builder class.
 * @return true if it's a static inner class.
 */
private static boolean isPossibleBuilderClass(Element possibleBuilderClass, ValueAttribute valueAttribute) {
  if (possibleBuilderClass.getKind() == ElementKind.CLASS) {

    if (valueAttribute.containingType.names().newTokenInAttributeBuilder()) {
      return possibleBuilderClass.getModifiers().contains(Modifier.STATIC)
          && possibleBuilderClass.getKind() == ElementKind.CLASS;
    }
  }

  return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:17,代碼來源:AttributeBuilderReflection.java

示例10: shouldProcessUndefined

/**
 * Determines if the Element should be processed as an undefined variable. Currently the implementation
 * only returns true if an undefinedSymbolScope is set, AND the undefined symbol might belong to that scope.
 * If the undefined symbol is qualified (by this. or class.this. or whatever else manner), the method will
 * only return true if the qualifier corresponds to the undefinedSymbolScope.
 * 
 */
private boolean shouldProcessUndefined(Element e) {
    if (e == null || undefinedSymbolScope == null ||
        e.asType().getKind() != TypeKind.ERROR) {
        return false;
    }
    if (e.getKind() == ElementKind.CLASS) {
        return referenceTarget == null || 
            referenceTarget == undefinedSymbolScope;
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:Flow.java

示例11: InnerToOuterRefactoringUI

/** Creates a new instance of InnerToOuterRefactoringUI
 * @param selectedElements Elements the refactoring action was invoked on.
 */
private InnerToOuterRefactoringUI(TreePathHandle sourceType, CompilationInfo info) {
    refactoring = new InnerToOuterRefactoring(sourceType);
    refactoring.setReferenceName("outer"); //NOI18N
    Element temp = sourceType.resolveElement(info);
    className = temp.getSimpleName().toString();
    disableDeclareFields = temp.getModifiers().contains(Modifier.STATIC) || temp.getKind() !=ElementKind.CLASS;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:InnerToOuterRefactoringUI.java

示例12: verify

/**
 * 校驗{@code moduleElement}的合法性
 *
 * @param moduleElement 攜帶@XModule的Element
 * @throws ProcessException
 */
private void verify(Element moduleElement) throws ProcessException {
    XModule XModule = moduleElement.getAnnotation(XModule.class);
    // 檢驗XModule注解
    if (XModule == null) {
        throw new ProcessException(
                String.format("當前的element(%s)未攜帶%s注解",
                        moduleElement.toString(),
                        XModule.class.getSimpleName()));
    } else if (XModule.name() == null || XModule.name().isEmpty()) {
        throw new ProcessException(String.format("%s的組件名不能為空", moduleElement.toString()));
    }

    // 檢驗被XModule注解的是否為class
    if (moduleElement.getKind() != ElementKind.CLASS) {
        throw new ProcessException(
                String.format("%s不是類,隻有類才能使用%s",
                        moduleElement.toString(),
                        XModule.class.getSimpleName()));
    }

    TypeElement classElement = (TypeElement) moduleElement;

    // 檢驗類修飾符
    Set<Modifier> modifiers = classElement.getModifiers();
    if (!modifiers.contains(Modifier.PUBLIC)) {
        throw new ProcessException(
                String.format("被%s注解的%s的權限修飾符必須為public",
                        XModule.class.getSimpleName(),
                        classElement.getQualifiedName().toString()));
    }
    if (modifiers.contains(Modifier.ABSTRACT)) {
        throw new ProcessException(
                String.format("%s是抽象類,不能被%s注解",
                        classElement.getQualifiedName().toString(),
                        XModule.class.getSimpleName()));
    }
}
 
開發者ID:xpleemoon,項目名稱:XModulable,代碼行數:43,代碼來源:XModuleProcessor.java

示例13: isPrimitiveWrapperType

public static boolean isPrimitiveWrapperType(TypeMirror tm) {
    if (tm == null || tm.getKind() != TypeKind.DECLARED) { 
        return false;
    }
    Element el = ((DeclaredType)tm).asElement();
    if (el == null || el.getKind() != ElementKind.CLASS) {
        return false;
    }
    String s = ((TypeElement)el).getQualifiedName().toString();
    return PRIMITIVE_NAMES.contains(s); // NOI18N
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:Utilities.java

示例14: createObjects

@Override
public List<T> createObjects(TypeElement type) {
    final List<T> result = new ArrayList<T>();
    if (type.getKind() == ElementKind.CLASS || type.getKind() == ElementKind.INTERFACE) {
        if (helper.hasAnyAnnotation(type.getAnnotationMirrors(), getAnnotationTypeNames())) {
            result.add(createObject(helper, type));
        }
    }
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:ObjectProviders.java

示例15: isRootObjectType

/**
 * Checks whether the given type object represents type
 * {@code java.lang.Object}.
 * 
 * @param  type  type to be checked
 * @return  {@code true} if the passed type object represents type
 *          {@code java.lang.Object}, {@code false} otherwise
 */
private static boolean isRootObjectType(DeclaredType type) {
    if (type.getKind() != TypeKind.DECLARED) {
        return false;
    }

    TypeElement elem = (TypeElement) type.asElement();
    return (elem.getKind() == ElementKind.CLASS)
           && (elem.getSuperclass().getKind() == TypeKind.NONE);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:AbstractTestGenerator.java


注:本文中的javax.lang.model.element.ElementKind.CLASS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。