/** * @return string representation of inspected class */ public String toString() { return getType().toString(); }
/** * Returns the simple name (i.e. full name with package name removed) of * the inspected Class. * @return inspected class simple name */ public String getName() { return getType().getSimpleName(); }
/** * Returns the fully-qualified name for the inspected Class. * @return inspected class name */ public String getFullName() { return getType().getName(); }
/** * Returns true if the inspected Class is declared public. * @return whether the inspected class is public */ public boolean isPublic() { return Modifier.isPublic(getType().getModifiers()); }
/** * Returns true if the inspected Class is an inner class * that has been declared static or is a standard outer class.. * @return whether the inspected class is static */ public boolean isStatic() { return Modifier.isStatic(getType().getModifiers()); }
/** * Returns true if the inspected Class is an interface. * @return whether the inspected class is an interface */ public boolean isInterface() { return Modifier.isInterface(getType().getModifiers()); }
/** * Returns true if the inspected Class is declared protected. * @return whether the inspected class is protected */ public boolean isProtected() { return Modifier.isProtected(getType().getModifiers()); }
/** * Returns true if the inspected Class is declared private. * @return whether the inspected class is private */ public boolean isPrivate() { return Modifier.isPrivate(getType().getModifiers()); }
/** * Returns true if the inspected Class is declared final. * @return whether the inspected class is final */ public boolean isFinal() { return Modifier.isFinal(getType().getModifiers()); }
/** * Returns the name of the package to which the inspected Class belongs. * @return package name */ public String getPackage() { return getType().getPackage().getName(); }
/** * Returns true if the inspected Class is declared abstract. * @return whether the inspected class is abstract */ public boolean isAbstract() { return Modifier.isAbstract(getType().getModifiers()); }
/** * Returns the {@link Annotation}s of the Class being inspected. * @return annotation list */ public List<Annotation> getAnnotations() { return Arrays.asList(getType().getAnnotations()); }
/** * Returns true if the inspected Class has been deprecated. * @return deprecation status */ public boolean isDeprecated() { return isDeprecated(getType()); }
/** * Returns true if the inspected Class is declared strictfp * (uses strict floating point math). * @return whether the inspected class is strictfp */ public boolean isStrict() { return Modifier.isStrict(getType().getModifiers()); }
/** * Returns a new ClassTool instance that is inspecting the * superclass of the Class being inspected by this instance. * If the current inspectee has no super class, * then this will return {@code null}. All other * configuration settings will be copied to the new instance. * @return parent class tool */ public ClassTool getSuper() { Class sup = getType().getSuperclass(); if (sup == null) { return null; } return inspect(sup); }
/** * Returns a {@link List} of {@link MethodSub}s for each * method declared method in the inspected class. However, * in safe mode (which *is* the default), this will only return * the public methods. You must configure safe mode to be off * to receive a list of all methods. * @return methods inspectors list */ public List<MethodSub> getMethods() { if (methods == null) { Method[] declared = getType().getDeclaredMethods(); List<MethodSub> subs = new ArrayList<MethodSub>(declared.length); for (Method method : declared) { MethodSub sub = new MethodSub(method); if ((!isSafeMode() || sub.isPublic()) && (showDeprecated || !sub.isDeprecated())) { subs.add(sub); } } Collections.sort(subs); methods = Collections.unmodifiableList(subs); } return methods; }
/** * Returns a {@link List} of {@link FieldSub}s for each * field declared field in the inspected class. However, * in safe mode (which *is* the default), this will only return * the public fields. You must configure safe mode to be off * to receive a list of all fields. * @return fields inspectors list */ public List<FieldSub> getFields() { if (fields == null) { Field[] declared = getType().getDeclaredFields(); List<FieldSub> subs = new ArrayList<FieldSub>(declared.length); for (Field field : declared) { FieldSub sub = new FieldSub(field); if ((!isSafeMode() || sub.isPublic()) && (showDeprecated || !sub.isDeprecated())) { subs.add(sub); } } Collections.sort(subs); fields = Collections.unmodifiableList(subs); } return fields; }
/** * Returns a {@link List} of {@link ConstructorSub}s for each * constructor declared constructor in the inspected class. However, * in safe mode (which *is* the default), this will only return * the public constructors. You must configure safe mode to be off * to receive a list of all constructors. * @return constructors inspectors list */ public List<ConstructorSub> getConstructors() { if (constructors == null) { Constructor[] declared = getType().getDeclaredConstructors(); List<ConstructorSub> subs = new ArrayList<ConstructorSub>(declared.length); for (Constructor constructor : declared) { ConstructorSub sub = new ConstructorSub(constructor); if ((!isSafeMode() || sub.isPublic()) && (showDeprecated || !sub.isDeprecated())) { subs.add(sub); } } Collections.sort(subs); constructors = Collections.unmodifiableList(subs); } return constructors; }