/** * Returns an iterable representing the collection of all fields declared in classes along the * path from the given leaf class to the {@link Object} base class. * * @return iterable representing the declared fields */ public static Iterable<Field> allDeclaredFields(final Object object) { Assert.objectNotNull(object, "object"); return new DeclaredFieldsIterable(object.getClass()); }
/** * Returns the package part of a fully qualified class name. * * @param className class name to extract the package name from * @return package name */ public static String getPackageName(final String className) { Assert.objectNotNull(className, "class name"); final int lastDotStart = className.lastIndexOf('.'); return (lastDotStart > 0) ? className.substring(0, lastDotStart) : ""; }
/** * Returns an iterable representing the collection of all classes along the path from leaf class * (determined from the given {@code object}) to the {@link Object} base class. * * @param object the object used to derive the leaf class from * @return iterable representing the classes */ public static Iterable<Class<?>> inheritanceChain(final Object object) { Assert.objectNotNull(object, "object"); return new InheritanceChainIterable(object.getClass()); }