List of usage examples for java.lang Class getModifiers
@HotSpotIntrinsicCandidate public native int getModifiers();
From source file:org.apache.asterix.om.typecomputer.TypeComputerTest.java
@Test public void test() throws Exception { // Several exceptional type computers. Set<String> exceptionalTypeComputers = new HashSet<>(); exceptionalTypeComputers.add("InjectFailureTypeComputer"); exceptionalTypeComputers.add("RecordAddFieldsTypeComputer"); exceptionalTypeComputers.add("OpenRecordConstructorResultType"); exceptionalTypeComputers.add("RecordRemoveFieldsTypeComputer"); exceptionalTypeComputers.add("ClosedRecordConstructorResultType"); exceptionalTypeComputers.add("LocalAvgTypeComputer"); exceptionalTypeComputers.add("BooleanOnlyTypeComputer"); exceptionalTypeComputers.add("AMissingTypeComputer"); exceptionalTypeComputers.add("NullableDoubleTypeComputer"); exceptionalTypeComputers.add("RecordMergeTypeComputer"); exceptionalTypeComputers.add("BooleanOrMissingTypeComputer"); // Tests all usual type computers. Reflections reflections = new Reflections("org.apache.asterix.om.typecomputer", new SubTypesScanner(false)); Set<Class<? extends IResultTypeComputer>> classes = reflections.getSubTypesOf(IResultTypeComputer.class); for (Class<? extends IResultTypeComputer> c : classes) { if (exceptionalTypeComputers.contains(c.getSimpleName()) || Modifier.isAbstract(c.getModifiers())) { continue; }/*from ww w . j a v a 2 s . co m*/ System.out.println("Test type computer: " + c.getName()); Assert.assertTrue(testTypeComputer(c)); } }
From source file:com.bstek.dorado.data.type.AbstractDataType.java
public void setMatchType(Class<?> matchType) { this.matchType = matchType; if (creationType == null && !matchType.isInterface() && !Modifier.isAbstract(matchType.getModifiers())) { creationType = matchType;/*from www . ja v a 2s . c o m*/ } }
From source file:it.uniroma2.sag.kelp.data.representation.structure.StructureElementFactory.java
/** * Retrieves all the implementations of the class * <code>StructureElement</code> included in the current project * /* w w w .java2 s. c o m*/ * @return a Map of pairs StructureElement type identifier - * StructureElement class */ private Map<String, Class<? extends StructureElement>> discoverAllStructureElementImplementations() throws InstantiationException, IllegalAccessException { Reflections reflections = new Reflections("it"); Set<Class<? extends StructureElement>> classes = reflections.getSubTypesOf(StructureElement.class); HashMap<String, Class<? extends StructureElement>> implementatios = new HashMap<String, Class<? extends StructureElement>>(); for (Class<? extends StructureElement> implementation : classes) { if (Modifier.isAbstract(implementation.getModifiers())) { continue; } String structureElementAbbreviation = getStructureElementIdentifier(implementation); implementatios.put(structureElementAbbreviation, implementation); } return implementatios; }
From source file:com.kinglcc.spring.jms.core.Jackson2PayloadArgumentResolver.java
private Object convertFromMessage(MethodParameter parameter, Message<?> message) { Object payload = message.getPayload(); Class<?> targetClass = parameter.getParameterType(); if (targetClass.isInterface() || Modifier.isAbstract(targetClass.getModifiers())) { return payload; }/*from www . j ava 2s . c o m*/ if (this.converter instanceof GenericMessageAdapterConverter) { payload = convertJavaTypeFromMessage(message, parameter); validate(message, parameter, payload); return payload; } payload = convertClassFromMessage(message, targetClass); validate(message, parameter, payload); return payload; }
From source file:com.retroduction.carma.resolvers.util.TestCaseInstantiationVerifier.java
public HashSet<String> determineUnloadableTestClassNames(Set<String> fqTestClassNames) { HashSet<String> unloadableClasses = new HashSet<String>(); for (String testClassName : fqTestClassNames) { try {// w w w. j a va 2s . co m Class<?> testClass = this.getLoader().loadClass(testClassName); if (Modifier.isAbstract(testClass.getModifiers()) || Modifier.isInterface(testClass.getModifiers())) { this.log.info("Skipping abstract class or interface in test set:" + testClassName); unloadableClasses.add(testClassName); continue; } } catch (Exception e) { this.log.warn("Skipping class in test set due to class loading problem:" + testClassName); this.log.debug(e); unloadableClasses.add(testClassName); continue; } catch (NoClassDefFoundError e) { this.log.warn("Skipping class in test set due to class loading problem:" + testClassName); this.log.debug(e); unloadableClasses.add(testClassName); continue; } } return unloadableClasses; }
From source file:org.spring.guice.module.GuiceModuleMetadata.java
private boolean visible(Class<?> type) { Class<?> cls = type; while (cls != null && cls != Object.class) { if (!Modifier.isInterface(cls.getModifiers()) && !Modifier.isPublic(cls.getModifiers()) && !Modifier.isProtected(cls.getModifiers())) { return false; }/*from www . j a v a 2 s . co m*/ cls = cls.getDeclaringClass(); } return true; }
From source file:tachyon.shell.TfsShell.java
/** * Uses reflection to get all the {@link TfsShellCommand} classes and store them in a map. *///from ww w.ja v a2s. c om private void loadCommands() { String pkgName = TfsShellCommand.class.getPackage().getName(); Reflections reflections = new Reflections(pkgName); for (Class<? extends TfsShellCommand> cls : reflections.getSubTypesOf(TfsShellCommand.class)) { // Only instantiate a concrete class if (!Modifier.isAbstract(cls.getModifiers())) { TfsShellCommand cmd; try { cmd = CommonUtils.createNewClassInstance(cls, new Class[] { TachyonConf.class, FileSystem.class }, new Object[] { mTachyonConf, mTfs }); } catch (Exception e) { throw Throwables.propagate(e); } mCommands.put(cmd.getCommandName(), cmd); } } }
From source file:plugins.ApiHelpInventory.java
private boolean isRessource(Class<?> javaClass) { // ignore interfaces and abstract classes if (javaClass.isInterface() || Modifier.isAbstract(javaClass.getModifiers())) { return false; }//from w w w. j a va 2 s. co m // check for @Path or @Provider annotation if (hasAnnotation(javaClass, Path.class)) { return true; } return false; }
From source file:pl.otros.logview.api.BaseLoader.java
public <T> List<Class<T>> getInterfaceImplementations(Class<T> interfaceClass, File f) throws IOException, ClassNotFoundException { ArrayList<Class<T>> list = new ArrayList<>(); List<String> classes = null; if (f.isDirectory()) { classes = getClassesFromDir(f);/*from w w w . jav a 2 s. c om*/ } else { classes = getClassesFromJar(f); } URL url = f.toURI().toURL(); ClassLoader cl = new URLClassLoader(new URL[] { url }, this.getClass().getClassLoader()); for (String klazz : classes) { try { Class<?> c = cl.loadClass(klazz); if (interfaceClass.isAssignableFrom(c) && !Modifier.isAbstract(c.getModifiers())) { list.add((Class<T>) c); } } catch (Throwable t) { LOGGER.warn(String.format("Error checking if class %s from file %s is implementing %s: %s", klazz, f, interfaceClass.getName(), t.getMessage())); } } return list; }
From source file:de.vandermeer.execs.Skb_Exec.java
/** * Adds a set of service at runtime, as in all found SKB services that can be executed * @param set a set of services//www . j a v a2 s.c om */ protected void addAllServices(Set<Class<?>> set) { for (Class<?> cls : set) { if (!cls.isInterface() && !Modifier.isAbstract(cls.getModifiers())) { if (!this.byClass.containsValue(cls)) { this.byName.add(cls.getName()); } } } }