List of usage examples for java.lang.reflect Modifier isStatic
public static boolean isStatic(int mod)
From source file:de.codesourcery.eve.skills.util.XMLMapper.java
private BeanDescription createBeanDescription(Class<?> clasz) { BeanDescription result = new BeanDescription(); for (java.lang.reflect.Field f : clasz.getDeclaredFields()) { final int modifiers = f.getModifiers(); if (Modifier.isFinal(modifiers) || Modifier.isStatic(modifiers) || Modifier.isTransient(modifiers)) { continue; }/*www. j av a 2 s . c o m*/ if (!f.isAccessible()) { f.setAccessible(true); } result.addField(f); } return result; }
From source file:org.jboss.arquillian.spring.integration.javaconfig.utils.DefaultConfigurationClassesProcessor.java
private void throwExceptionIfConfiguratoinClassNotDeclaredStatic(Class<?> configurationCandidate) { if (!Modifier.isStatic(configurationCandidate.getModifiers())) { throw new RuntimeException(buildValidationMessage(configurationCandidate, VALIDATION_MESSAGE_SUFFIX_INNER_CLASS_DECLARED_NOT_STATIC)); }/*from w w w . j a v a 2s.c o m*/ }
From source file:com.github.wshackle.java4cpp.J4CppMain.java
private static String getCppModifiers(int modifiers) { String out = ""; if (Modifier.isStatic(modifiers)) { out += "static "; }/*from w w w. ja v a 2 s .c o m*/ return out; }
From source file:com.opengamma.financial.analytics.ircurve.CurveSpecificationBuilderConfiguration.java
private static List<String> getCurveSpecBuilderConfigurationNames() { final List<String> list = new ArrayList<>(); for (final Field field : CurveSpecificationBuilderConfigurationFudgeBuilder.class.getDeclaredFields()) { if (Modifier.isStatic(field.getModifiers()) && field.isSynthetic() == false) { field.setAccessible(true);/*w w w.ja v a 2 s . com*/ try { list.add((String) field.get(null)); } catch (final Exception ex) { // Ignore } } } Collections.sort(list, String.CASE_INSENSITIVE_ORDER); return ImmutableList.copyOf(list); }
From source file:bammerbom.ultimatecore.bukkit.configuration.ConfigurationSerialization.java
protected Method getMethod(String name, boolean isStatic) { try {//from w w w .j av a2s .c o m Method method = clazz.getDeclaredMethod(name, Map.class); if (!ConfigurationSerializable.class.isAssignableFrom(method.getReturnType())) { return null; } if (Modifier.isStatic(method.getModifiers()) != isStatic) { return null; } return method; } catch (NoSuchMethodException ex) { return null; } catch (SecurityException ex) { return null; } }
From source file:net.radai.beanz.util.ReflectionUtil.java
public static boolean isStatic(Field field) { return Modifier.isStatic(field.getModifiers()); }
From source file:com.sunchenbin.store.feilong.core.lang.reflect.FieldUtil.java
/** * ?field?list.// w w w . j a va2s . com * * <h3>??:</h3> * * <blockquote> * <ol> * <li>{@code if isNullOrEmpty(fields) return emptyList}</li> * <li>(?,) {@link #getAllFields(Object)}</li> * <li> <code>excludeFieldNames</code></li> * <li> {@link Modifier#isPrivate(int)} and {@link Modifier#isStatic(int)}</li> * </ol> * </blockquote> * * @param obj * the obj * @param excludeFieldNames * ?field names,?nullOrEmpty ? * @return the field value map * @see #getAllFields(Object) * @since 1.4.0 */ public static List<Field> getAllFieldList(Object obj, String[] excludeFieldNames) { // (?,) Field[] fields = getAllFields(obj); if (Validator.isNullOrEmpty(fields)) { return Collections.emptyList(); } List<Field> fieldList = new ArrayList<Field>(); for (Field field : fields) { String fieldName = field.getName(); if (Validator.isNotNullOrEmpty(excludeFieldNames) && ArrayUtils.contains(excludeFieldNames, fieldName)) { continue; } int modifiers = field.getModifiers(); // ??? log boolean isPrivateAndStatic = Modifier.isPrivate(modifiers) && Modifier.isStatic(modifiers); LOGGER.debug("field name:[{}],modifiers:[{}],isPrivateAndStatic:[{}]", fieldName, modifiers, isPrivateAndStatic); if (!isPrivateAndStatic) { fieldList.add(field); } } return fieldList; }
From source file:org.apache.openaz.xacml.std.json.JSONResponse.java
/** * Use reflection to load the map with all the names of all DataTypes allowing us to output the shorthand * version rather than the full Identifier name. (to shorten the JSON output). The shorthand map is used * differently in JSONRequest than in JSONResponse, so there are similarities and differences in the * implementation. This is done once the first time a Request is processed. */// w w w .ja v a 2 s . co m private static void initOutputShorthandMap() throws JSONStructureException { Field[] declaredFields = XACML3.class.getDeclaredFields(); outputShorthandMap = new HashMap<String, String>(); for (Field field : declaredFields) { if (Modifier.isStatic(field.getModifiers()) && field.getName().startsWith("ID_DATATYPE") && Modifier.isPublic(field.getModifiers())) { try { Identifier id = (Identifier) field.get(null); String longName = id.stringValue(); // most names start with 'http://www.w3.org/2001/XMLSchema#' int sharpIndex = longName.lastIndexOf("#"); if (sharpIndex <= 0) { // some names start with 'urn:oasis:names:tc:xacml:1.0:data-type:' // or urn:oasis:names:tc:xacml:2.0:data-type: if (longName.contains(":data-type:")) { sharpIndex = longName.lastIndexOf(":"); } else { continue; } } String shortName = longName.substring(sharpIndex + 1); // put both the full name and the short name in the table outputShorthandMap.put(id.stringValue(), shortName); } catch (Exception e) { throw new JSONStructureException("Error loading ID Table, e=" + e); } } } }
From source file:de.micromata.genome.util.strings.ReducedReflectionToStringBuilder.java
@Override protected boolean accept(Field field) { // if (field.getName().indexOf(ClassUtils.INNER_CLASS_SEPARATOR_CHAR) != -1) { // // Reject field from inner class. // return false; // }/*from www . j a v a2 s . co m*/ if (field.getAnnotation(NoStringifyAnnotation.class) != null) { return false; } if (Modifier.isTransient(field.getModifiers()) && !this.isAppendTransients()) { // transients. return false; } if (Modifier.isStatic(field.getModifiers()) && !this.isAppendStatics()) { // transients. return false; } return true; }
From source file:org.castor.jaxb.reflection.ClassInfoBuilder.java
/** * Checks if the Method is describeable. * //from www.j a v a 2s . c om * @param type * the Class of the Method * @param method * the Method to check * @return true if the method is describeable */ private boolean isDescribeable(final Class<?> type, final Method method) { boolean isDescribeable = true; Class<?> declaringClass = method.getDeclaringClass(); if ((declaringClass != null) && !type.equals(declaringClass) && (!declaringClass.isInterface())) { isDescribeable = false; } if (method.isSynthetic()) { isDescribeable &= false; } if (Modifier.isStatic(method.getModifiers())) { isDescribeable &= false; } if (Modifier.isTransient(method.getModifiers())) { isDescribeable &= false; } if (!(javaNaming.isAddMethod(method) || javaNaming.isCreateMethod(method) || javaNaming.isGetMethod(method) || javaNaming.isIsMethod(method) || javaNaming.isSetMethod(method))) { isDescribeable = false; } return isDescribeable; }