List of usage examples for java.lang.reflect Modifier isProtected
public static boolean isProtected(int mod)
From source file:com.impetus.kundera.utils.KunderaCoreUtils.java
/** * @param clazz//from w ww. j av a 2 s . c o m * @return */ public static Object createNewInstance(Class clazz) { Object target = null; try { Constructor[] constructors = clazz.getDeclaredConstructors(); for (Constructor constructor : constructors) { if ((Modifier.isProtected(constructor.getModifiers()) || Modifier.isPublic(constructor.getModifiers())) && constructor.getParameterTypes().length == 0) { constructor.setAccessible(true); target = constructor.newInstance(); constructor.setAccessible(false); break; } } return target; } catch (InstantiationException iex) { logger.error("Error while creating an instance of {} .", clazz); throw new PersistenceException(iex); } catch (IllegalAccessException iaex) { logger.error("Illegal Access while reading data from {}, Caused by: .", clazz, iaex); throw new PersistenceException(iaex); } catch (Exception e) { logger.error("Error while creating an instance of {}, Caused by: .", clazz, e); throw new PersistenceException(e); } }
From source file:org.apache.openjpa.util.ProxyManagerImpl.java
private static boolean isProxyable(Class<?> cls) { int mod = cls.getModifiers(); if (Modifier.isFinal(mod)) return false; if (Modifier.isProtected(mod) || Modifier.isPublic(mod)) return true; // Default scoped class, we can only extend if it is in the same package as the generated proxy. Ideally // we'd fix the code gen portion and place proxies in the same pacakge as the types being proxied. if (cls.getPackage().getName().equals("org.apache.openjpa.util")) return true; return false; }
From source file:org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.java
public static boolean isProtected(Constructor<?> constructor) { return Modifier.isProtected(constructor.getModifiers()); }
From source file:org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.java
public static boolean isProtected(Method method) { return Modifier.isProtected(method.getModifiers()); }
From source file:org.eclipse.wb.internal.core.utils.reflect.ReflectionUtils.java
public static boolean isProtected(Field field) { return Modifier.isProtected(field.getModifiers()); }
From source file:h2o.common.spring.util.ClassUtils.java
/** * Determine whether the given method is overridable in the given target class. * @param method the method to check//from w w w. j av a 2 s . c om * @param targetClass the target class to check against */ @SuppressWarnings("rawtypes") private static boolean isOverridable(Method method, Class targetClass) { if (Modifier.isPrivate(method.getModifiers())) { return false; } if (Modifier.isPublic(method.getModifiers()) || Modifier.isProtected(method.getModifiers())) { return true; } return getPackageName(method.getDeclaringClass()).equals(getPackageName(targetClass)); }
From source file:com.laidians.utils.ClassUtils.java
/** * Determine whether the given method is overridable in the given target class. * @param method the method to check/*from ww w .j a va 2 s. co m*/ * @param targetClass the target class to check against */ private static boolean isOverridable(Method method, Class targetClass) { if (Modifier.isPrivate(method.getModifiers())) { return false; } if (Modifier.isPublic(method.getModifiers()) || Modifier.isProtected(method.getModifiers())) { return true; } return getPackageName(method.getDeclaringClass()).equals(getPackageName(targetClass)); }
From source file:com.dianping.resource.io.util.ClassUtils.java
/** * Determine whether the given method is overridable in the given target class. * @param method the method to check/*from w w w. ja va 2s .c o m*/ * @param targetClass the target class to check against */ private static boolean isOverridable(Method method, Class<?> targetClass) { if (Modifier.isPrivate(method.getModifiers())) { return false; } if (Modifier.isPublic(method.getModifiers()) || Modifier.isProtected(method.getModifiers())) { return true; } return getPackageName(method.getDeclaringClass()).equals(getPackageName(targetClass)); }
From source file:com.freetmp.common.util.ClassUtils.java
private static boolean isOverridable(Method method, Class<?> targetClass) { if (Modifier.isPrivate(method.getModifiers())) { return false; }/*from w w w. j a v a 2 s . com*/ if (Modifier.isPublic(method.getModifiers()) || Modifier.isProtected(method.getModifiers())) { return true; } return getPackageName(method.getDeclaringClass()).equals(getPackageName(targetClass)); }
From source file:com.github.wshackle.java4cpp.J4CppMain.java
public static boolean hasNoArgConstructor(Constructor[] constructors) { for (Constructor c : constructors) { if ((Modifier.isProtected(c.getModifiers()) || Modifier.isPublic(c.getModifiers())) && c.getParameterTypes().length == 0) { return true; }//ww w . j av a2 s . c om } return false; }