/** * Get the {@link ClassInfo} object for the referenced class, or null if the referenced class was not * encountered during scanning (i.e. no ClassInfo object was created for the class during scanning). N.B. even * if this method returns null, {@link #loadClass()} may be able to load the referenced class by name. * * @return The {@link ClassInfo} object for the referenced class. */ ClassInfo getClassInfo() { if (classInfo == null) { if (scanResult == null) { return null; } final String className = getClassName(); if (className == null) { throw new IllegalArgumentException("Class name is not set"); } classInfo = scanResult.getClassInfo(className); } return classInfo; }
/** * Load the class named returned by {@link #getClassInfo()}, or if that returns null, the class named by * {@link #getClassName()}. Returns a {@code Class<?>} reference for the class. * * @param ignoreExceptions * If true, ignore classloading exceptions and return null on failure. * @return The {@code Class<?>} reference for the referenced class, or null if the class could not be loaded and * ignoreExceptions is true. * @throws IllegalArgumentException * if the class could not be loaded and ignoreExceptions was false. */ Class<?> loadClass(final boolean ignoreExceptions) { if (classRef == null) { String className; final ClassInfo classInfo = getClassInfo(); if (classInfo != null) { // Get class name from getClassInfo().getName() className = classInfo.getName(); } else { // Get class name from getClassName() className = getClassName(); } if (className == null) { throw new IllegalArgumentException("Class name is not set"); } classRef = scanResult.loadClass(className, ignoreExceptions); } return classRef; }
} else { className = getClassName();