List of usage examples for java.lang.reflect Modifier ABSTRACT
int ABSTRACT
To view the source code for java.lang.reflect Modifier ABSTRACT.
Click Source Link
From source file:Main.java
public static void main(String... args) throws Exception { Class<?> c = Class.forName("java.lang.String"); Constructor[] allConstructors = c.getDeclaredConstructors(); for (Constructor ctor : allConstructors) { int searchMod = Modifier.ABSTRACT; int mods = accessModifiers(ctor.getModifiers()); if (searchMod == mods) { System.out.println(ctor); }// ww w.j a va2 s .c o m } }
From source file:Main.java
/** * Helper method that checks if given class is a concrete one; * that is, not an interface or abstract class. *///from w w w. j av a 2 s .c o m public static boolean isConcrete(Class<?> type) { int mod = type.getModifiers(); return (mod & (Modifier.INTERFACE | Modifier.ABSTRACT)) == 0; }
From source file:Main.java
public static boolean isConcrete(Member member) { int mod = member.getModifiers(); return (mod & (Modifier.INTERFACE | Modifier.ABSTRACT)) == 0; }
From source file:Main.java
private static int accessModifiers(int m) { return m & Modifier.ABSTRACT; }
From source file:gov.nih.nci.caarray.external.v1_0.AbstractCaArrayEntityTest.java
public static <T> List<Class<? extends T>> findLocalSubclasses(Class<T> c) throws ClassNotFoundException, URISyntaxException { List<Class<? extends T>> l = new ArrayList<Class<? extends T>>(); File dir = new File(c.getProtectionDomain().getCodeSource().getLocation().toURI()); Iterator<File> fi = FileUtils.iterateFiles(dir, new String[] { "class" }, true); int prefix = dir.getAbsolutePath().length() + 1; int suffix = ".class".length(); while (fi.hasNext()) { File cf = fi.next();/* www. j av a 2 s . c o m*/ String fn = cf.getAbsolutePath(); try { String cn = fn.substring(prefix, fn.length() - suffix); if (cn.endsWith("<error>")) { continue; } cn = cn.replace('/', '.'); System.out.println("cn = " + cn); Class tmp = c.getClassLoader().loadClass(cn); if ((tmp.getModifiers() & Modifier.ABSTRACT) != 0) { continue; } if (c.isAssignableFrom(tmp)) { l.add(tmp); System.out.println("added " + cf.getAbsolutePath() + " as " + cn); } } catch (Exception e) { System.err.println(fn); e.printStackTrace(); } } return l; }
From source file:com.edmunds.autotest.ClassUtil.java
public static boolean isStandardClass(Class cls) { return !(((cls.getModifiers() & Modifier.ABSTRACT) > 0) || cls.isInterface() || cls.isMemberClass() || cls.isLocalClass() || cls.isSynthetic()); }
From source file:com.khs.sherpa.endpoint.SherpaEndpoint.java
@SuppressWarnings("unchecked") // @RolesAllowed("SHERPA_ADMIN") @Action(mapping = "/sherpa/admin/describe/{value}") public Object describe(@Param("value") String value) { List<Map<String, Object>> actions = new ArrayList<Map<String, Object>>(); Set<Method> methods = null; try {/*w w w . j ava 2s. com*/ methods = Reflections.getAllMethods(applicationContext.getType(value), Predicates.and(Predicates.not(SherpaPredicates.withAssignableFrom(Object.class)), ReflectionUtils.withModifier(Modifier.PUBLIC), Predicates.not(ReflectionUtils.withModifier(Modifier.ABSTRACT)), Predicates.not(SherpaPredicates.withGeneric()))); } catch (NoSuchManagedBeanExcpetion e) { throw new SherpaRuntimeException(e); } for (Method method : methods) { Map<String, Object> action = new HashMap<String, Object>(); actions.add(action); action.put("name", MethodUtil.getMethodName(method)); if (method.isAnnotationPresent(DenyAll.class)) { action.put("permission", "DenyAll"); } else if (method.isAnnotationPresent(RolesAllowed.class)) { action.put("permission", "RolesAllowed"); action.put("roles", method.getAnnotation(RolesAllowed.class).value()); } else { action.put("permission", "PermitAll"); } Map<String, String> params = new HashMap<String, String>(); Class<?>[] types = method.getParameterTypes(); Annotation[][] parameters = method.getParameterAnnotations(); for (int i = 0; i < parameters.length; i++) { Class<?> type = types[i]; Param annotation = null; if (parameters[i].length > 0) { for (Annotation an : parameters[i]) { if (an.annotationType().isAssignableFrom(Param.class)) { annotation = (Param) an; break; } } } if (annotation != null) { params.put(annotation.value(), type.getName()); } } if (params.size() > 0) { action.put("params", params); } else { action.put("params", null); } } return actions; }
From source file:com.github.geequery.codegen.ast.JavaMethod.java
public void setAbstract(boolean isAbstract) { if (isAbstract != isAbstract()) { modifier ^= Modifier.ABSTRACT; } }
From source file:com.link_intersystems.lang.reflect.criteria.MemberCriteriaTest.java
@SuppressWarnings("unchecked") @Test/*from www .j a v a 2s . c o m*/ public void publicAbstractMethodStartingWithAdd() { memberCriteria.membersOfType(Method.class); memberCriteria.withModifiers(Modifier.ABSTRACT); memberCriteria.named(Pattern.compile("add.*")); memberCriteria.setMemberIterateOrder(ReflectFacade.getMemberNameComparator()); Collection<Class<?>> iteratedTypes = new ArrayList<Class<?>>(Arrays.asList(List.class, Collection.class)); ClassCriteria classCriteria = new ClassCriteria(); Iterable<Class<?>> classIterable = classCriteria.getIterable(ArrayList.class); Iterable<Member> memberIterable = memberCriteria.getIterable(classIterable); assertTrue(memberIterable.iterator().hasNext()); for (Member member : memberIterable) { assertTrue("member must be a method", member instanceof Method); iteratedTypes.remove(member.getDeclaringClass()); String name = member.getName(); assertTrue(name.startsWith("add")); int modifiers = member.getModifiers(); assertTrue(Modifier.isAbstract(modifiers)); } assertTrue("Some types have not been iterated. " + iteratedTypes, iteratedTypes.isEmpty()); }
From source file:hu.bme.mit.sette.common.model.snippet.SnippetInputFactoryContainer.java
/** * Validates the class and its annotations. * * @param validator// w w w . java 2 s . com * a validator */ private void validateClass(final AbstractValidator<?> validator) { // check: "public final class", no superclass, interface, declared // class, exactly one constructor ClassValidator v = new ClassValidator(javaClass); v.type(ClassType.REGULAR_CLASS); v.withModifiers(Modifier.PUBLIC | Modifier.FINAL); v.withoutModifiers(Modifier.ABSTRACT); v.synthetic(false); v.superclass(Object.class).interfaceCount(0).memberClassCount(0); v.declaredConstructorCount(1); // check: no SETTE annotations if (!SetteAnnotationUtils.getSetteAnnotations(javaClass).isEmpty()) { v.addException("The class must not have any SETTE annotations"); } validator.addChildIfInvalid(v); }