Java 8 Element - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Element class.

This code example shows how to use the following methods:asType, getSimpleName
		validatorHelper.canBePutInABundle(element, valid);
	} 
 
	@Override 
	public void process(Element element, HasInstanceState holder) {
		JClass elementClass = codeModelHelper.typeMirrorToJClass(element.asType(), holder);
		String fieldName = element.getSimpleName().toString();
 
		JBlock saveStateBody = holder.getSaveStateMethodBody();
		JVar saveStateBundleParam = holder.getSaveStateBundleParam();
		JMethod restoreStateMethod = holder.getRestoreStateMethod();
		JBlock restoreStateBody = restoreStateMethod.body();
		JVar restoreStateBundleParam = holder.getRestoreStateBundleParam();
 
		TypeMirror type = codeModelHelper.getActualType(element, holder);
 
		BundleHelper bundleHelper = new BundleHelper(annotationHelper, type);
 
		JFieldRef ref = ref(fieldName);
		saveStateBody.invoke(saveStateBundleParam, bundleHelper.getMethodNameToSave()).arg(fieldName).arg(ref);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:asType, getSimpleName
		validatorHelper.isNotPrivate(element, valid);
	} 
 
	@Override 
	public void process(Element element, EActivityHolder holder) throws JClassAlreadyExistsException {
		String fieldName = element.getSimpleName().toString();
		JClass fieldType = codeModelHelper.typeMirrorToJClass(element.asType(), holder);
 
		NonConfigurationHolder ncHolder = holder.getNonConfigurationHolder();
		JFieldVar ncHolderField = ncHolder.createField(fieldName, fieldType);
 
		injectInInit(element, holder, fieldName, ncHolderField);
		retainInOnRetain(holder, fieldName, ncHolderField);
	} 
 
	private void injectInInit(Element element, EActivityHolder holder, String fieldName, JFieldVar ncHolderField) throws JClassAlreadyExistsException {
		JBlock initIfNonConfigurationNotNullBlock = holder.getInitIfNonConfigurationNotNullBlock();
		JVar initNonConfigurationInstance = holder.getInitNonConfigurationInstance();
		initIfNonConfigurationNotNullBlock.assign(ref(fieldName), initNonConfigurationInstance.ref(ncHolderField));
		rebindContextIfBean(element, initIfNonConfigurationNotNullBlock, ncHolderField);
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getModifiers, getSuperclass
    @Override 
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
            ElementScanner6<Void,Void> scanner = new ElementScanner6<Void, Void>() {
                @Override 
                public Void visitType(TypeElement e, Void aVoid) {
                    if(!e.getModifiers().contains(Modifier.ABSTRACT)) {
                        Element sc = processingEnv.getTypeUtils().asElement(e.getSuperclass());
                        if (sc!=null && ((TypeElement)sc).getQualifiedName().contentEquals(HUDSON_PLUGIN_QUAFIFIER)) {
                            try { 
                                write(e);
                            } catch (IOException x) {
                                StringWriter sw = new StringWriter();
                                x.printStackTrace(new PrintWriter(sw));
                                processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR,sw.toString(),e);
                            } 
                        } 
                    } 
 
                    return super.visitType(e, aVoid);
                } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:asType, getSimpleName
		validatorHelper.isNotPrivate(element, valid);
	} 
 
	@Override 
	public void process(Element element, EComponentHolder holder) {
		String fieldName = element.getSimpleName().toString();
		String applicationQualifiedName = element.asType().toString();
		JClass applicationClass = refClass(applicationQualifiedName + ModelConstants.GENERATION_SUFFIX);
 
		holder.getInitBody().assign(ref(fieldName), applicationClass.staticInvoke(EApplicationHolder.GET_APPLICATION_INSTANCE));
	} 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:asType, getAnnotationMirrors, getModifiers, getConstantValue, getSimpleName
  private final String summary;
 
  public FieldSummary(VariableElement element) {
    StringBuilder builder = new StringBuilder();
 
    builder.append(Annotations.printAnnotations(element.getAnnotationMirrors()));
    builder.append(Modifiers.printModifiers(element.getModifiers()));
 
    builder.append(element.asType())
        .append(" ")
        .append(element.getSimpleName());
 
    // If the field represents a compile-time constant (and therefore might be inlined) we need to 
    // capture the default value. 
    if (isCompileTimeConstant(element)) {
      builder.append(" = ").append(element.getConstantValue());
    } 
 
    builder.append("\n");
 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:asType, getAnnotationMirrors, getModifiers, getConstantValue, getSimpleName
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
 
class RenderableTypes { 
 
  public Renderable deriveFor(Element element) {
    if (element.getModifiers().contains(Modifier.PRIVATE)) {
      return new EmptySummary(); 
    } 
 
    switch (element.getKind()) {
      case ANNOTATION_TYPE:
      case CLASS:
      case ENUM:
      case INTERFACE:
        return new TypeSummary(this, (TypeElement) element);
 
      case CONSTRUCTOR:
        return new ConstructorSummary((ExecutableElement) element);

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:asType, getSimpleName
		validatorHelper.isNotPrivate(element, valid);
	} 
 
	@Override 
	public void process(Element element, EComponentHolder holder) {
		String fieldName = element.getSimpleName().toString();
 
		TypeMirror serviceType = element.asType();
		String fieldTypeQualifiedName = serviceType.toString();
 
		JFieldRef serviceRef = androidSystemServices.getServiceConstant(serviceType, holder);
 
		JBlock methodBody = holder.getInitBody();
 
		methodBody.assign(ref(fieldName), cast(refClass(fieldTypeQualifiedName), holder.getContextRef().invoke("getSystemService").arg(serviceRef)));
	} 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:asType, getModifiers, getConstantValue, getSimpleName
 
public class FieldsGenerator { 
 
	private static void validateField(VariableElement field) {
		// Check if field is "public static final" 
		Set<Modifier> modifiers = field.getModifiers();
		if ( modifiers.size() != 3
		     || !modifiers.contains(Modifier.PUBLIC)
		     || !modifiers.contains(Modifier.STATIC)
		     || !modifiers.contains(Modifier.FINAL) ) {
			throw new RuntimeException("Field " + field.getSimpleName() + " is not declared public static final");
		} 
 
		// Check suported types (int, long, float, String) 
		TypeMirror field_type = field.asType();
		if ( "java.lang.String".equals(field_type.toString()) ) {
		} else if ( field_type instanceof PrimitiveType ) {
			PrimitiveType field_type_prim = (PrimitiveType)field_type;
			TypeKind field_kind = field_type_prim.getKind();
			if ( field_kind != TypeKind.INT

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAnnotation, getQualifiedName
  private final Binding<?>[] bindings; 
  private final String supertypeKey;
 
  private GraphAnalysisInjectBinding(String provideKey, String membersKey,
      TypeElement type, List<String> keys, String supertypeKey) {
    super(provideKey, membersKey, type.getAnnotation(Singleton.class) != null,
        type.getQualifiedName().toString());
    this.type = type;
    this.keys = keys;
    this.bindings = new Binding<?>[keys.size()];
    this.supertypeKey = supertypeKey;
  } 
 
  static GraphAnalysisInjectBinding create(TypeElement type, boolean mustHaveInjections) {
    List<String> requiredKeys = new ArrayList<String>();
    boolean hasInjectConstructor = false;
    boolean hasNoArgsConstructor = false;
 
    for (Element enclosed : type.getEnclosedElements()) {
      switch (enclosed.getKind()) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:asType, getSimpleName
        validatorHelper.typeHasAnnotation(Rest.class, element, valid);
    } 
 
    @Override 
    public void process(Element element, EComponentHolder holder) {
        String fieldName = element.getSimpleName().toString();
 
        TypeMirror fieldTypeMirror = element.asType();
        String interfaceName = fieldTypeMirror.toString();
 
        String generatedClassName = interfaceName + ModelConstants.GENERATION_SUFFIX;
 
        JBlock methodBody = holder.getInitBody();
 
        JFieldRef field = JExpr.ref(fieldName);
 
        methodBody.assign(field, JExpr._new(refClass(generatedClassName)).arg(holder.getContextRef()));
    } 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 Element Methods: