Java Code Examples for javax.lang.model.element.Modifier#PROTECTED

The following examples show how to use javax.lang.model.element.Modifier#PROTECTED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityGenerator.java    From requery with Apache License 2.0 6 votes vote down vote up
private Modifier[] generatedMemberModifiers(Modifier... modifiers) {
    Modifier visibility = null;
    switch (entity.propertyVisibility()) {
        case PUBLIC:
            visibility = Modifier.PUBLIC;
            break;
        case PRIVATE:
            if (entity.isEmbedded()) {
                visibility = Modifier.PROTECTED;
            } else {
                visibility = Modifier.PRIVATE;
            }
            break;
        case PACKAGE:
            break;
    }
    ArrayList<Modifier> list = new ArrayList<>();
    if (visibility != null) {
        list.add(visibility);
    }
    Collections.addAll(list, modifiers);
    return list.toArray(new Modifier[list.size()]);
}
 
Example 2
Source File: ProcessingUtils.java    From aircon with MIT License 5 votes vote down vote up
public static Modifier getVisibilityModifier(Element element) {
	switch (Visibility.ofElement(element)) {
		case PRIVATE:
			return Modifier.PRIVATE;
		case PROTECTED:
			return Modifier.PROTECTED;
		case PUBLIC:
			return Modifier.PUBLIC;
	}

	return null;
}
 
Example 3
Source File: ModifierOrderer.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
     * Returns the {@link Modifier} for the given token kind, or {@code
     * null}.
     */
    private static Modifier getModifier(TokenKind kind) {
        if (kind == null) {
            return null;
        }
        switch (kind) {
            case PUBLIC:
                return Modifier.PUBLIC;
            case PROTECTED:
                return Modifier.PROTECTED;
            case PRIVATE:
                return Modifier.PRIVATE;
            case ABSTRACT:
                return Modifier.ABSTRACT;
            case STATIC:
                return Modifier.STATIC;
            // TODO: 22-Jul-17 unsupported lambdas expr
//            case DEFAULT:
//                return Modifier.DEFAULT;
            case FINAL:
                return Modifier.FINAL;
            case TRANSIENT:
                return Modifier.TRANSIENT;
            case VOLATILE:
                return Modifier.VOLATILE;
            case SYNCHRONIZED:
                return Modifier.SYNCHRONIZED;
            case NATIVE:
                return Modifier.NATIVE;
            case STRICTFP:
                return Modifier.STRICTFP;
            default:
                return null;
        }
    }
 
Example 4
Source File: PsiModifierExtractor.java    From litho with Apache License 2.0 5 votes vote down vote up
private static Modifier psiModifierToModifier(PsiElement psiModifier) {
  switch (psiModifier.getText()) {
    case PsiModifier.ABSTRACT:
      return Modifier.ABSTRACT;
    case PsiModifier.FINAL:
      return Modifier.FINAL;
    case PsiModifier.NATIVE:
      return Modifier.NATIVE;
    case PsiModifier.PRIVATE:
      return Modifier.PRIVATE;
    case PsiModifier.PROTECTED:
      return Modifier.PROTECTED;
    case PsiModifier.PUBLIC:
      return Modifier.PUBLIC;
    case PsiModifier.STATIC:
      return Modifier.STATIC;
    case PsiModifier.STRICTFP:
      return Modifier.STRICTFP;
    case PsiModifier.SYNCHRONIZED:
      return Modifier.SYNCHRONIZED;
    case PsiModifier.TRANSIENT:
      return Modifier.TRANSIENT;
    case PsiModifier.VOLATILE:
      return Modifier.VOLATILE;
    default:
      // TODO better error message, ideally w/ line number
      throw new ComponentsProcessingException(
          "Unexpected Modifier, modifier is: " + psiModifier.getText());
  }
}
 
Example 5
Source File: ModifierOrderer.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
     * Returns the {@link Modifier} for the given token kind, or {@code
     * null}.
     */
    private static Modifier getModifier(TokenKind kind) {
        if (kind == null) {
            return null;
        }
        switch (kind) {
            case PUBLIC:
                return Modifier.PUBLIC;
            case PROTECTED:
                return Modifier.PROTECTED;
            case PRIVATE:
                return Modifier.PRIVATE;
            case ABSTRACT:
                return Modifier.ABSTRACT;
            case STATIC:
                return Modifier.STATIC;
            // TODO: 22-Jul-17 unsupported lambdas expr
//            case DEFAULT:
//                return Modifier.DEFAULT;
            case FINAL:
                return Modifier.FINAL;
            case TRANSIENT:
                return Modifier.TRANSIENT;
            case VOLATILE:
                return Modifier.VOLATILE;
            case SYNCHRONIZED:
                return Modifier.SYNCHRONIZED;
            case NATIVE:
                return Modifier.NATIVE;
            case STRICTFP:
                return Modifier.STRICTFP;
            default:
                return null;
        }
    }
 
Example 6
Source File: ModifierOrderer.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the {@link javax.lang.model.element.Modifier} for the given token kind, or {@code
 * null}.
 */
private static Modifier getModifier(TokenKind kind) {
  if (kind == null) {
    return null;
  }
  switch (kind) {
    case PUBLIC:
      return Modifier.PUBLIC;
    case PROTECTED:
      return Modifier.PROTECTED;
    case PRIVATE:
      return Modifier.PRIVATE;
    case ABSTRACT:
      return Modifier.ABSTRACT;
    case STATIC:
      return Modifier.STATIC;
    case DEFAULT:
      return Modifier.DEFAULT;
    case FINAL:
      return Modifier.FINAL;
    case TRANSIENT:
      return Modifier.TRANSIENT;
    case VOLATILE:
      return Modifier.VOLATILE;
    case SYNCHRONIZED:
      return Modifier.SYNCHRONIZED;
    case NATIVE:
      return Modifier.NATIVE;
    case STRICTFP:
      return Modifier.STRICTFP;
    default:
      return null;
  }
}
 
Example 7
Source File: VisibilityChanged.java    From revapi with Apache License 2.0 5 votes vote down vote up
private Modifier getVisibility(Element t) {
    for (Modifier m : t.getModifiers()) {
        if (m == Modifier.PUBLIC || m == Modifier.PROTECTED || m == Modifier.PRIVATE) {
            return m;
        }
    }

    return null;
}
 
Example 8
Source File: JavaPersistenceGenerator.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
protected void initialize() throws IOException {
    newClassTree = genUtils.ensureNoArgConstructor(newClassTree);
    if (genSerializableEntities && !UpdateType.UPDATE.equals(updateType)) {
        newClassTree = genUtils.addImplementsClause(newClassTree, "java.io.Serializable"); // NOI18N
    }
    if (needsPKClass && existingEmbeddedId == null) {
        String pkFieldName = createFieldName(pkClassName);
        pkProperty = new Property(
                Modifier.PROTECTED,
                Collections.singletonList(genUtils.createAnnotation("javax.persistence.EmbeddedId")),
                null,
                pkFQClassName,
                pkFieldName);
        properties.add(pkProperty);
    }

    if (UpdateType.UPDATE.equals(updateType)) {
        collectExistingColumns();
    } else {
        newClassTree = genUtils.addAnnotation(newClassTree, genUtils.createAnnotation(generateMappedSC ? "javax.persistence.MappedSuperclass" : "javax.persistence.Entity")); // NOI18N
        List<ExpressionTree> tableAnnArgs = new ArrayList<ExpressionTree>();
        if(useDefaults && entityClassName.equalsIgnoreCase(dbMappings.getTableName())){
            //skip
        } else if(dbMappings.getTableName() != null) {
            tableAnnArgs.add(genUtils.createAnnotationArgument("name", dbMappings.getTableName())); // NOI18N
        }
        if (fullyQualifiedTableNames) {
            String schemaName = entityClass.getSchemaName();
            String catalogName = entityClass.getCatalogName();
            if (catalogName != null) {
                tableAnnArgs.add(genUtils.createAnnotationArgument("catalog", catalogName)); // NOI18N
            }
            if (schemaName != null) {
                tableAnnArgs.add(genUtils.createAnnotationArgument("schema", schemaName)); // NOI18N
            }
        }

        // UniqueConstraint annotations for the table
        if (regenTablesAttrs && entityClass.getUniqueConstraints() != null
                && !entityClass.getUniqueConstraints().isEmpty()) {
            List<ExpressionTree> uniqueConstraintAnnotations = new ArrayList<ExpressionTree>();
            for (List<String> constraintCols : entityClass.getUniqueConstraints()) {

                List<ExpressionTree> colArgs = new ArrayList<ExpressionTree>();
                for (String colName : constraintCols) {
                    colArgs.add(genUtils.createAnnotationArgument(null, colName));
                }
                ExpressionTree columnNamesArg = genUtils.createAnnotationArgument("columnNames", colArgs); // NOI18N
                uniqueConstraintAnnotations.add(genUtils.createAnnotation("javax.persistence.UniqueConstraint",
                        Collections.singletonList(columnNamesArg))); //NOI18N
            }

            tableAnnArgs.add(genUtils.createAnnotationArgument("uniqueConstraints", uniqueConstraintAnnotations)); // NOI18N
        }

        if(!useDefaults || !tableAnnArgs.isEmpty()) {
            newClassTree = genUtils.addAnnotation(newClassTree, genUtils.createAnnotation("javax.persistence.Table", tableAnnArgs));//NOI18N
        }

        if (generateJAXBAnnotations) {
            newClassTree = genUtils.addAnnotation(newClassTree, genUtils.createAnnotation("javax.xml.bind.annotation.XmlRootElement"));//NOI18N
            /**
             * see #228733
             * if(jaxbOrder) {
                //ArrayList <ExpressionTree> fL = new ArrayList<ExpressionTree> ();
                //fL.add(genUtils.createAnnotation);
                //newClassTree = genUtils.addAnnotation(newClassTree, genUtils.createAnnotation("javax.xml.bind.annotation.XmlAccessorType", null);//NOI18N
                ArrayList ls = new ArrayList();
                List<ExpressionTree> nms = new ArrayList<ExpressionTree>();
                nms.add(genUtils.createAnnotationArgument(null,pkProperty.getField().getName()));
                for (EntityMember mem : entityClass.getFields()) {
                    if(!mem.isPrimaryKey()) {
                        nms.add(genUtils.createAnnotationArgument(null,mem.getMemberName()));
                    }
                }
                for (RelationshipRole mem : entityClass.getRoles()) {
                    nms.add(genUtils.createAnnotationArgument(null,mem.getFieldName()));
                }
                ls.add(genUtils.createAnnotationArgument("propOrder", nms));//NOI18N
                newClassTree = genUtils.addAnnotation(newClassTree, genUtils.createAnnotation("javax.xml.bind.annotation.XmlType",ls));//NOI18N
            }**/
        }

    }

    //TODO: javadoc - generate or fake in test mode
    //        b.setCommentDataAuthor(authorOverride);
    //        b.setCommentDataDate(dateOverride);
}
 
Example 9
Source File: LocalCacheContext.java    From caffeine with Apache License 2.0 4 votes vote down vote up
public Modifier[] protectedFinalModifiers() {
  return isFinal
      ? new Modifier[] { Modifier.PROTECTED }
      : new Modifier[] { Modifier.PROTECTED, Modifier.FINAL };
}