List of usage examples for java.lang.reflect Modifier isAbstract
public static boolean isAbstract(int mod)
From source file:net.sf.juffrou.reflect.JuffrouTypeConverterDelegate.java
private boolean canCreateCopy(Class requiredType) { return (!requiredType.isInterface() && !Modifier.isAbstract(requiredType.getModifiers()) && Modifier.isPublic(requiredType.getModifiers()) && ClassUtils.hasConstructor(requiredType)); }
From source file:org.integratedmodelling.thinklab.plugin.ThinklabPlugin.java
protected void loadCommandHandlers() throws ThinklabException { String ipack = this.getClass().getPackage().getName() + ".commands"; for (Class<?> cls : MiscUtilities.findSubclasses(ICommandHandler.class, ipack, getClassLoader())) { /*// w w w . j av a 2 s .c o m * lookup annotation, ensure we can use the class */ if (cls.isInterface() || Modifier.isAbstract(cls.getModifiers())) continue; /* * lookup implemented concept */ for (Annotation annotation : cls.getAnnotations()) { if (annotation instanceof ThinklabCommand) { String name = ((ThinklabCommand) annotation).name(); String description = ((ThinklabCommand) annotation).description(); CommandDeclaration declaration = new CommandDeclaration(name, description); String retType = ((ThinklabCommand) annotation).returnType(); if (!retType.equals("")) declaration.setReturnType(KnowledgeManager.get().requireConcept(retType)); String[] aNames = ((ThinklabCommand) annotation).argumentNames().split(","); String[] aTypes = ((ThinklabCommand) annotation).argumentTypes().split(","); String[] aDesc = ((ThinklabCommand) annotation).argumentDescriptions().split(","); for (int i = 0; i < aNames.length; i++) { if (!aNames[i].isEmpty()) declaration.addMandatoryArgument(aNames[i], aDesc[i], aTypes[i]); } String[] oaNames = ((ThinklabCommand) annotation).optionalArgumentNames().split(","); String[] oaTypes = ((ThinklabCommand) annotation).optionalArgumentTypes().split(","); String[] oaDesc = ((ThinklabCommand) annotation).optionalArgumentDescriptions().split(","); String[] oaDefs = ((ThinklabCommand) annotation).optionalArgumentDefaultValues().split(","); for (int i = 0; i < oaNames.length; i++) { if (!oaNames[i].isEmpty()) declaration.addOptionalArgument(oaNames[i], oaDesc[i], oaTypes[i], oaDefs[i]); } String[] oNames = ((ThinklabCommand) annotation).optionNames().split(","); String[] olNames = ((ThinklabCommand) annotation).optionLongNames().split(","); String[] oaLabel = ((ThinklabCommand) annotation).optionArgumentLabels().split(","); String[] oTypes = ((ThinklabCommand) annotation).optionTypes().split(","); String[] oDesc = ((ThinklabCommand) annotation).optionDescriptions().split(","); for (int i = 0; i < oNames.length; i++) { if (!oNames[i].isEmpty()) declaration.addOption(oNames[i], olNames[i], (oaLabel[i].equals("") ? null : oaLabel[i]), oDesc[i], oTypes[i]); } try { CommandManager.get().registerCommand(declaration, (ICommandHandler) cls.newInstance()); } catch (Exception e) { throw new ThinklabValidationException(e); } break; } } } }
From source file:org.codehaus.groovy.grails.compiler.injection.GrailsASTUtils.java
public static boolean isCandidateMethod(MethodNode declaredMethod) { return !declaredMethod.isSynthetic() && !declaredMethod.getName().contains("$") && Modifier.isPublic(declaredMethod.getModifiers()) && !Modifier.isAbstract(declaredMethod.getModifiers()); }
From source file:org.springframework.beans.TypeConverterDelegate.java
private boolean canCreateCopy(Class<?> requiredType) { return (!requiredType.isInterface() && !Modifier.isAbstract(requiredType.getModifiers()) && Modifier.isPublic(requiredType.getModifiers()) && ClassUtils.hasConstructor(requiredType)); }
From source file:org.zaproxy.zap.control.AddOnLoader.java
public <T> List<T> getImplementors(AddOn ao, String packageName, Class<T> classType) { Class<?> cls = null;// w w w .j a va2s .c o m List<T> listClass = new ArrayList<>(); List<ClassNameWrapper> classNames; if (ao != null) { classNames = this.getJarClassNames(ao, packageName); } else { classNames = this.getClassNames(packageName, classType); } for (ClassNameWrapper classWrapper : classNames) { try { cls = classWrapper.getCl().loadClass(classWrapper.getClassName()); // abstract class or interface cannot be constructed. if (Modifier.isAbstract(cls.getModifiers()) || Modifier.isInterface(cls.getModifiers())) { continue; } if (classType.isAssignableFrom(cls)) { @SuppressWarnings("unchecked") Constructor<T> c = (Constructor<T>) cls.getConstructor(); listClass.add(c.newInstance()); } } catch (Throwable e) { // Often not an error logger.debug(e.getMessage()); } } return listClass; }
From source file:org.latticesoft.util.common.StringUtil.java
public static String formatObjectToString(Object o, boolean includeChild) { if (o == null) return ""; if (o == null) return ""; StringBuffer sb = new StringBuffer(); String className = o.getClass().getName(); sb.append("["); sb.append(className);/* w ww . j av a 2s.c o m*/ sb.append("|"); // list of attributes Field f[] = o.getClass().getDeclaredFields(); WrapDynaBean dyn = null; try { dyn = new WrapDynaBean(o); } catch (Exception e) { } for (int i = 0; i < f.length; i++) { String name = f[i].getName(); int modifier = f[i].getModifiers(); if (Modifier.isFinal(modifier) || Modifier.isAbstract(modifier) || Modifier.isInterface(modifier) || Modifier.isStatic(modifier)) { continue; } Object value = null; try { value = dyn.get(name); } catch (Exception e) { //if (log.isErrorEnabled()) { log.error(e); } } if (name != null && value != null) { sb.append(name); sb.append("="); if (value instanceof Map) { Map map = (Map) value; if (includeChild) { sb.append(value); } else { sb.append(map.size()); } sb.append("|"); } else if (value instanceof Collection) { Collection c = (Collection) value; if (includeChild) { sb.append(value); } else { sb.append(c.size()); } sb.append("|"); } else { sb.append(value); sb.append("|"); } } } sb.deleteCharAt(sb.length() - 1); sb.append("]"); return sb.toString(); }
From source file:org.apache.openjpa.enhance.ApplicationIdTool.java
/** * Return true if this class has a concrete superclass. *//*from w w w .ja v a2 s. com*/ private boolean hasConcreteSuperclass() { for (ClassMetaData sup = _meta.getPCSuperclassMetaData(); sup != null; sup = sup .getPCSuperclassMetaData()) { if (!Modifier.isAbstract(sup.getDescribedType().getModifiers())) return true; } return false; }
From source file:org.gvnix.service.roo.addon.addon.ws.export.WSExportOperationsImpl.java
/** * {@inheritDoc}//from w w w . jav a 2s .c o m **/ public List<String> getServiceList() { List<String> classNames = new ArrayList<String>(); // Gets all classes annotated with @GvNIxWebService Set<ClassOrInterfaceTypeDetails> cids = typeLocationService .findClassesOrInterfaceDetailsWithAnnotation(new JavaType(GvNIXWebService.class.getName())); for (ClassOrInterfaceTypeDetails cid : cids) { // Exclude abstract classes if (Modifier.isAbstract(cid.getModifier())) { continue; } classNames.add(cid.getName().getFullyQualifiedTypeName()); } return classNames; }
From source file:org.integratedmodelling.thinklab.plugin.ThinklabPlugin.java
protected void loadListingProviders() throws ThinklabException { String ipack = this.getClass().getPackage().getName() + ".commands"; for (Class<?> cls : MiscUtilities.findSubclasses(IListingProvider.class, ipack, getClassLoader())) { /*/*from www.j av a2 s.c o m*/ * lookup annotation, ensure we can use the class */ if (cls.isInterface() || Modifier.isAbstract(cls.getModifiers())) continue; for (Annotation annotation : cls.getAnnotations()) { if (annotation instanceof ListingProvider) { String name = ((ListingProvider) annotation).label(); String sname = ((ListingProvider) annotation).itemlabel(); try { CommandManager.get().registerListingProvider(name, sname, (IListingProvider) cls.newInstance()); } catch (Exception e) { throw new ThinklabValidationException(e); } break; } } } }
From source file:com.gatf.generator.core.GatfTestGeneratorMojo.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private Object getObject(Class claz, List<Type> heirarchies) throws Exception { if (claz.isEnum()) return claz.getEnumConstants()[0]; if (isMap(claz)) { return getMapValue(claz, claz.getTypeParameters(), heirarchies); } else if (isCollection(claz)) { return getListSetValue(claz, claz.getTypeParameters(), heirarchies); } else if (claz.isInterface() || Modifier.isAbstract(claz.getModifiers())) { return null; }// www. j ava 2 s .c o m if (heirarchies.contains(claz) || heirarchies.size() >= 2) return null; heirarchies.add(claz); Constructor cons = null; try { cons = claz.getConstructor(new Class[] {}); } catch (Exception e) { getLog().error("No public no-args constructor found for class " + claz.getName()); return null; } Object object = cons.newInstance(new Object[] {}); List<Field> allFields = getAllFields(claz); for (Field field : allFields) { if (Modifier.isStatic(field.getModifiers())) continue; if (!field.isAccessible()) { field.setAccessible(true); } List<Type> fheirlst = new ArrayList<Type>(heirarchies); if (isDebugEnabled()) getLog().info("Parsing Class " + getHeirarchyStr(fheirlst) + " field " + field.getName() + " type " + field.getType().equals(boolean.class)); if (isPrimitive(field.getType())) { field.set(object, getPrimitiveValue(field.getType())); } else if (isMap(field.getType())) { ParameterizedType type = (ParameterizedType) field.getGenericType(); field.set(object, getMapValue(field.getType(), type.getActualTypeArguments(), fheirlst)); } else if (isCollection(field.getType())) { ParameterizedType type = (ParameterizedType) field.getGenericType(); field.set(object, getListSetValue(field.getType(), type.getActualTypeArguments(), fheirlst)); } else if (!claz.equals(field.getType())) { Object fieldval = getObject(field.getType(), fheirlst); field.set(object, fieldval); } else if (claz.equals(field.getType())) { if (isDebugEnabled()) getLog().info("Ignoring recursive fields..."); } } return object; }