List of usage examples for java.lang.reflect Modifier PROTECTED
int PROTECTED
To view the source code for java.lang.reflect Modifier PROTECTED.
Click Source Link
From source file:com.hihframework.core.utils.ReflectUtil.java
public static final Method[] getProtectedMethods(Object obj, String prefix) { return getMethods(obj, Modifier.PROTECTED, prefix); }
From source file:org.gvnix.web.screen.roo.addon.EntityBatchMetadata.java
/** * Generates field (list) metadata for ListInner class using * <code>name</code> as field name * // w w w . j ava2s. c o m * @param name to use to * @param listType list item type * @return */ private FieldMetadataBuilder getListInner_field(String name, JavaType listType) { List<JavaType> typeParams = new ArrayList<JavaType>(); typeParams.add(listType); JavaType fieldType = new JavaType("java.util.List", 0, DataType.TYPE, null, typeParams); FieldMetadataBuilder fieldBuilder = new FieldMetadataBuilder(getId(), Modifier.PROTECTED, new JavaSymbolName(name), fieldType, MessageFormat.format("new java.util.ArrayList<{0}>()", new Object[] { listType.getSimpleTypeName() })); if (name.equals("list")) { // Annotate List field with javax.validation.Valid List<AnnotationMetadataBuilder> annotations = new ArrayList<AnnotationMetadataBuilder>(1); AnnotationMetadataBuilder validAnnotationBuilder = new AnnotationMetadataBuilder( new JavaType("javax.validation.Valid")); annotations.add(validAnnotationBuilder); fieldBuilder.setAnnotations(annotations); } return fieldBuilder; }
From source file:hd3gtv.mydmam.db.orm.CassandraOrm.java
private ArrayList<Field> getOrmobjectUsableFields() { ArrayList<Field> result = new ArrayList<Field>(); Field[] fields = this.reference.getFields(); Field field;/* www. j a v a2 s . c om*/ int mod; for (int pos_df = 0; pos_df < fields.length; pos_df++) { field = fields[pos_df]; if (field.isAnnotationPresent(Transient.class)) { /** * Is transient ? */ continue; } if (field.getName().equals("key")) { /** * Not this (primary key) */ continue; } mod = field.getModifiers(); if ((mod & Modifier.PROTECTED) != 0) continue; if ((mod & Modifier.PRIVATE) != 0) continue; if ((mod & Modifier.ABSTRACT) != 0) continue; if ((mod & Modifier.STATIC) != 0) continue; if ((mod & Modifier.FINAL) != 0) continue; if ((mod & Modifier.TRANSIENT) != 0) continue; if ((mod & Modifier.INTERFACE) != 0) continue; try { result.add(field); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } } return result; }
From source file:org.xulux.dataprovider.bean.BeanMapping.java
/** * Will discover the fields in the bean. * if discovery is set and discovery has not yet taken * place. Discovery will methods which are private or protected. * /*from w w w. j a v a2 s. c o m*/ * It will also try to discover the set method that is connected * to the getter (assuming it is not a read only field). * * @todo What to do with collections ? */ public void discover() { if (!isDiscovered && isDiscovery()) { Method[] methods = bean.getMethods(); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if ((!method.getName().equals("getClass") && method.getModifiers() != Modifier.PRIVATE && method.getModifiers() != Modifier.PROTECTED)) { BeanField field = new BeanField(method); // try to find the setter.. String fieldName = field.getName(); if (fieldName.length() > 0) { fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1); } Method setMethod = findMethod(fieldName, true); field.setChangeMethod(setMethod); BeanField previousField = (BeanField) getField(fieldName); if (previousField != null) { if (previousField.getMethod().getParameterTypes().length == 0) { continue; } else { if (field.getMethod().getParameterTypes().length == 0) { fields.remove(previousField); } } } addField(field); } } isDiscovered = true; } }
From source file:org.gradle.build.docs.dsl.source.SourceMetaDataVisitor.java
private int extractModifiers(GroovySourceAST ast) { GroovySourceAST modifiers = ast.childOfType(MODIFIERS); if (modifiers == null) { return 0; }/* w w w. ja v a2 s . c om*/ int modifierFlags = 0; for (GroovySourceAST child = (GroovySourceAST) modifiers .getFirstChild(); child != null; child = (GroovySourceAST) child.getNextSibling()) { switch (child.getType()) { case LITERAL_private: modifierFlags |= Modifier.PRIVATE; break; case LITERAL_protected: modifierFlags |= Modifier.PROTECTED; break; case LITERAL_public: modifierFlags |= Modifier.PUBLIC; break; case FINAL: modifierFlags |= Modifier.FINAL; break; case LITERAL_static: modifierFlags |= Modifier.STATIC; break; } } return modifierFlags; }
From source file:com.link_intersystems.lang.reflect.criteria.MemberCriteriaTest.java
@Test(expected = IllegalArgumentException.class) public void illegalModifierProtected() { memberCriteria.withModifiers(Modifier.PROTECTED); }
From source file:org.eclipse.buildship.docs.source.SourceMetaDataVisitor.java
private int extractModifiers(GroovySourceAST ast) { GroovySourceAST modifiers = ast.childOfType(MODIFIERS); if (modifiers == null) { return 0; }//from w w w . j a v a 2 s.c om int modifierFlags = 0; for (GroovySourceAST child = (GroovySourceAST) modifiers .getFirstChild(); child != null; child = (GroovySourceAST) child.getNextSibling()) { switch (child.getType()) { case LITERAL_private: modifierFlags |= Modifier.PRIVATE; break; case LITERAL_protected: modifierFlags |= Modifier.PROTECTED; break; case LITERAL_public: modifierFlags |= Modifier.PUBLIC; break; case FINAL: modifierFlags |= Modifier.FINAL; break; case LITERAL_static: modifierFlags |= Modifier.STATIC; break; case ABSTRACT: modifierFlags |= Modifier.ABSTRACT; break; } } return modifierFlags; }
From source file:com.link_intersystems.lang.reflect.criteria.MemberCriteria.java
@SuppressWarnings("unchecked") protected Iterator<T> applyAccessAndNamePredicates(Iterator<T> iterator) { List<Predicate<?>> predicates = new ArrayList<Predicate<?>>(); int accessModifiers = 0; Collection<AccessType> accesses = getAccesses(); for (AccessType access : accesses) { switch (access) { case PUBLIC: accessModifiers |= Modifier.PUBLIC; break; case PRIVATE: accessModifiers |= Modifier.PRIVATE; break; case PROTECTED: accessModifiers |= Modifier.PROTECTED; break; default://from www .j a va2 s. c om break; } } Predicate<Member> accessModifierPredicate = new MemberModifierPredicate(accessModifiers, Match.AT_LEAST_ONE); if (accesses.contains(AccessType.DEFAULT)) { accessModifierPredicate = OrPredicate.orPredicate(accessModifierPredicate, NotPredicate.notPredicate(new MemberModifierPredicate( Modifier.PRIVATE | Modifier.PUBLIC | Modifier.PROTECTED, Match.AT_LEAST_ONE))); } predicates.add(accessModifierPredicate); int modifiers = getModifiers(); if (modifiers != 0) { predicates.add(new MemberModifierPredicate(modifiers, Match.AT_LEAST_ALL)); } String name = getName(); if (name != null) { predicates.add(ReflectFacade.getMemberNamePredicate(name)); } Pattern pattern = getPattern(); if (pattern != null) { predicates.add(ReflectFacade.getMemberNamePatternPredicate(pattern)); } Predicate<T> allPredicate = AllPredicate.allPredicate((Collection<? extends Predicate<T>>) predicates); iterator = IteratorUtils.filteredIterator(iterator, allPredicate); return iterator; }
From source file:com.facebook.ads.sdk.Ad.java
synchronized /*package*/ static Gson getGson() { if (gson != null) { return gson; } else {/*ww w .j ava 2 s .c o m*/ gson = new GsonBuilder().excludeFieldsWithModifiers(Modifier.STATIC) .excludeFieldsWithModifiers(Modifier.PROTECTED).disableHtmlEscaping().create(); } return gson; }