List of usage examples for java.lang.reflect Modifier isPrivate
public static boolean isPrivate(int mod)
From source file:com.mstiles92.plugins.stileslib.config.ConfigObject.java
protected boolean doSkip(Field field) { return Modifier.isTransient(field.getModifiers()) || Modifier.isStatic(field.getModifiers()) || Modifier.isFinal(field.getModifiers()) || Modifier.isProtected(field.getModifiers()) || Modifier.isPrivate(field.getModifiers()); }
From source file:adalid.core.EntityAtlas.java
private void finaliseFields() { String name;// w ww. j a va 2 s .c o m Class<?> type; int modifiers; boolean restricted; Object o; int depth = _declaringArtifact.depth(); int round = _declaringArtifact.round(); int index = _declaringArtifact.getStartWith(); Class<?>[] classes = new Class<?>[] { Property.class, Key.class, Tab.class, View.class, Instance.class, NamedValue.class, Expression.class, Transition.class, Operation.class, Trigger.class }; Class<?> dac = _declaringArtifact.getClass(); Class<?> top = Entity.class; for (Class<?> c : classes) { for (Field field : XS1.getFields(dac, top)) { field.setAccessible(true); logger.trace(field); name = field.getName(); type = field.getType(); if (!c.isAssignableFrom(type)) { continue; } if (c.equals(Expression.class) && Property.class.isAssignableFrom(type)) { continue; } modifiers = field.getModifiers(); restricted = Modifier.isPrivate(modifiers); if (restricted) { continue; } restricted = Modifier.isStatic(modifiers) || Modifier.isFinal(modifiers); if (restricted) { continue; } String errmsg = "failed to initialize field \"" + field + "\" at " + _declaringArtifact; try { o = field.get(_declaringArtifact); if (o == null) { logger.debug(message(type, name, o, depth, round)); } else if (o instanceof Property) { finaliseProperty(field, (Property) o); } else if (o instanceof Key) { finaliseKey(field, (Key) o); } else if (o instanceof Tab) { finaliseTab(field, (Tab) o); } else if (o instanceof View) { finaliseView(field, (View) o); } else if (o instanceof Instance) { finaliseInstance(field, (Instance) o, index++); } else if (o instanceof NamedValue) { finaliseNamedValue(field, (NamedValue) o); } else if (o instanceof Expression) { finaliseExpression(field, (Expression) o); } else if (o instanceof Transition) { finaliseTransition(field, (Transition) o); } else if (o instanceof Operation) { finaliseOperation(field, (Operation) o); } else if (o instanceof Trigger) { finaliseTrigger(field, (Trigger) o); } } catch (IllegalArgumentException | IllegalAccessException ex) { logger.error(errmsg, ThrowableUtils.getCause(ex)); TLC.getProject().getParser().increaseErrorCount(); } } } }
From source file:de.codesourcery.eve.apiclient.parsers.HttpAPIClientTest.java
private static Method findParserMethod(String name, Class<?>... args) throws Exception { try {/*from w w w. j a va 2s .co m*/ return AbstractResponseParser.class.getDeclaredMethod(name, args); } catch (Exception e) { try { return AbstractResponseParser.class.getMethod(name, args); } catch (Exception e2) { for (Method m : AbstractResponseParser.class.getMethods()) { if (!m.getName().equals(name)) { System.out.println("# Name mismatch: " + m); continue; } if (!ObjectUtils.equals(m.getParameterTypes(), args)) { System.out.println("# Param mismatch: " + m); continue; } final int modifiers = m.getModifiers(); if (Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers) || Modifier.isFinal(modifiers)) { System.out.println("# Modifier mismatch: " + m); continue; } return m; } throw e2; } } }
From source file:fr.certu.chouette.command.Command.java
private void executeInfoValidationParameters() throws Exception { try {/* w w w . ja v a2 s . co m*/ Class<?> c = validationParameters.getClass(); Field[] fields = c.getDeclaredFields(); for (Field field : fields) { if (field.getName().equals("test3_2_Polygon")) continue; int m = field.getModifiers(); if (Modifier.isPrivate(m) && !Modifier.isStatic(m)) { printField(c, field, ""); } } } catch (Exception e) { e.printStackTrace(); throw e; } }
From source file:com.parse.ParseObject.java
private static boolean isAccessible(Member m) { return Modifier.isPublic(m.getModifiers()) || (m.getDeclaringClass().getPackage().getName().equals("com.parse") && !Modifier.isPrivate(m.getModifiers()) && !Modifier.isProtected(m.getModifiers())); }
From source file:org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.java
public static boolean isPrivate(Constructor<?> constructor) { return Modifier.isPrivate(constructor.getModifiers()); }
From source file:org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.java
public static boolean isPrivate(Method method) { return Modifier.isPrivate(method.getModifiers()); }
From source file:org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.java
public static boolean isPrivate(Field field) { return Modifier.isPrivate(field.getModifiers()); }
From source file:org.evosuite.instrumentation.mutation.ReplaceVariable.java
/** * This replicates TestUsageChecker.canUse but we need to avoid that * we try to access Properties.getTargetClassAndDontInitialise * * @param f//from w w w. ja va2 s. com * @return */ public static boolean canUse(Field f) { if (f.getDeclaringClass().equals(java.lang.Object.class)) return false;// handled here to avoid printing reasons if (f.getDeclaringClass().equals(java.lang.Thread.class)) return false;// handled here to avoid printing reasons if (f.isSynthetic()) { logger.debug("Skipping synthetic field " + f.getName()); return false; } if (f.getName().startsWith("ajc$")) { logger.debug("Skipping AspectJ field " + f.getName()); return false; } // in, out, err if (f.getDeclaringClass().equals(FileDescriptor.class)) { return false; } if (Modifier.isPublic(f.getModifiers())) { // It may still be the case that the field is defined in a non-visible superclass of the class // we already know we can use. In that case, the compiler would be fine with accessing the // field, but reflection would start complaining about IllegalAccess! // Therefore, we set the field accessible to be on the safe side TestClusterUtils.makeAccessible(f); return true; } // If default access rights, then check if this class is in the same package as the target class if (!Modifier.isPrivate(f.getModifiers())) { String packageName = ClassUtils.getPackageName(f.getDeclaringClass()); if (packageName.equals(Properties.CLASS_PREFIX)) { TestClusterUtils.makeAccessible(f); return true; } } return false; }
From source file:adalid.core.AbstractArtifact.java
private boolean isNotRestricted(Field field) { int modifiers = field.getModifiers(); return !(Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers) || Modifier.isFinal(modifiers)); }