List of usage examples for java.lang Class getModifiers
@HotSpotIntrinsicCandidate public native int getModifiers();
From source file:org.apache.tajo.ws.rs.resources.outputs.RestOutputFactory.java
private static Map<String, String> load() { Map<String, String> outputClasses = Maps.newHashMap(); Set<Class> restOutputClasses = ClassUtil.findClasses(AbstractStreamingOutput.class, "org.apache.tajo.ws.rs.resources.outputs"); for (Class eachClass : restOutputClasses) { if (eachClass.isInterface() || Modifier.isAbstract(eachClass.getModifiers())) { continue; }/*from w ww . j a va2 s. com*/ AbstractStreamingOutput streamingOutput = null; try { streamingOutput = (AbstractStreamingOutput) eachClass .getDeclaredConstructor( new Class[] { NonForwardQueryResultScanner.class, Integer.class, Integer.class }) .newInstance(null, 0, 0); } catch (Exception e) { LOG.warn(eachClass + " cannot instantiate Function class because of " + e.getMessage(), e); continue; } String className = streamingOutput.getClass().getCanonicalName(); String headerType = streamingOutput.getClass().getAnnotation(RestReturnType.class).mimeType(); if (StringUtils.isNotEmpty(headerType)) { outputClasses.put(headerType, className); } } return outputClasses; }
From source file:org.springframework.test.context.support.AnnotationConfigContextLoaderUtils.java
private static boolean isStaticNonPrivateAndNonFinal(Class<?> clazz) { Assert.notNull(clazz, "Class must not be null"); int modifiers = clazz.getModifiers(); return (Modifier.isStatic(modifiers) && !Modifier.isPrivate(modifiers) && !Modifier.isFinal(modifiers)); }
From source file:natalia.dymnikova.cluster.scheduler.impl.Codec.java
private static Object doSanitize(final Object f) { final Class<?> aClass = f.getClass(); if (!isStatic(aClass.getModifiers())) { final Class<?> enclosingClass = aClass.getEnclosingClass(); if (enclosingClass != null) { for (final Field field : aClass.getDeclaredFields()) { if (enclosingClass.equals(field.getType())) { field.setAccessible(true); try { field.set(f, null); } catch (final IllegalAccessException e) { throw unchecked(e); }/* w w w . ja v a 2 s . co m*/ } } } } return f; }
From source file:org.jiemamy.utils.reflect.ModifierUtil.java
/** * {@code abstract}??????/*from w w w .j ava 2 s . c o m*/ * * @param clazz * @return {@code abstract}????{@code true}?????????{@code false} * @throws IllegalArgumentException ?{@code null}??? */ public static boolean isAbstract(Class<?> clazz) { Validate.notNull(clazz); return Modifier.isAbstract(clazz.getModifiers()); }
From source file:com.jaspersoft.jasperserver.jrsh.operation.PackageScanClassResolver.java
/** * Discovers the packages retrieves operation types. * * @param basePackage package to scan//w ww.ja v a 2 s. c o m * @return operation classes */ public static Set<Class<? extends Operation>> findOperationClasses(String basePackage) { HashSet<Class<? extends Operation>> operationTypes = new HashSet<>(); MetadataScannerConfig config = readConfig(); List<String> externalPackagesToScan = config.getPackagesToScan(); List<String> classes = config.getClasses(); FilterBuilder filter = new FilterBuilder().includePackage(basePackage); // // Discover external operation types from configuration file // if (classes != null) { for (String aClass : classes) { try { Class clz = Class.forName(aClass); if (!Modifier.isAbstract(clz.getModifiers()) && Operation.class.isAssignableFrom(clz)) { operationTypes.add(clz); } } catch (ClassNotFoundException ignored) { } } } // // Prepare package filter to avoid unnecessary CP scanning // if (externalPackagesToScan != null) { for (String aPackage : externalPackagesToScan) { aPackage = chomp(aPackage, ".*"); filter.includePackage(aPackage); } } // // Retrieve internal operation types // Reflections ref = new Reflections(new SubTypesScanner(), filter); for (val subType : ref.getSubTypesOf(Operation.class)) { if (!Modifier.isAbstract(subType.getModifiers())) { operationTypes.add(subType); } } return operationTypes; }
From source file:com.github.dozermapper.core.classmap.ClassMappings.java
private static boolean isAbstract(Class<?> destClass) { return Modifier.isAbstract(destClass.getModifiers()); }
From source file:org.apache.brooklyn.util.javalang.MethodAccessibleReflections.java
static boolean isAccessible(Class<?> c) { return c != null && Modifier.isPublic(c.getModifiers()); }
From source file:org.mabb.fontverter.FontVerter.java
private static List<Class> removeAbstractClasses(List<Class> classes) { List<Class> filtered = new ArrayList<Class>(); for (Class adapterOn : classes) { if (!Modifier.isAbstract(adapterOn.getModifiers())) filtered.add(adapterOn);/*from w w w . ja v a 2 s .c om*/ } return filtered; }
From source file:org.spongepowered.common.util.ReflectionUtil.java
public static <T> T createInstance(final Class<T> objectClass, Object... args) { checkArgument(!Modifier.isAbstract(objectClass.getModifiers()), "Cannot construct an instance of an abstract class!"); checkArgument(!Modifier.isInterface(objectClass.getModifiers()), "Cannot construct an instance of an interface!"); if (args == null) { args = new Object[] { null }; }// w ww .j ava 2 s . c o m final Constructor<T> ctor = findConstructor(objectClass, args); try { return ctor.newInstance(args); } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { SpongeImpl.getLogger().error("Couldn't find an appropriate constructor for " + objectClass.getCanonicalName() + "with the args: " + Arrays.toString(args), e); } throw new IllegalArgumentException("Couldn't find an appropriate constructor for " + objectClass.getCanonicalName() + "the args: " + Arrays.toString(args)); }
From source file:ca.uhn.fhir.util.ReflectionUtil.java
public static boolean isInstantiable(Class<?> theType) { return !theType.isInterface() && !Modifier.isAbstract(theType.getModifiers()); }