Search in sources :

Example 1 with APIResource

use of com.stripe.net.APIResource in project stripe-java by stripe.

the class StandardizationTest method getAllModels.

private Collection<Class> getAllModels() throws IOException {
    Class<Charge> chargeClass = Charge.class;
    ClassPath classPath = ClassPath.from(chargeClass.getClassLoader());
    ImmutableSet<ClassPath.ClassInfo> topLevelClasses = classPath.getTopLevelClasses(chargeClass.getPackage().getName());
    List<Class> classList = Lists.newArrayListWithExpectedSize(topLevelClasses.size());
    for (ClassPath.ClassInfo classInfo : topLevelClasses) {
        Class c = classInfo.load();
        // Skip things that aren't APIResources
        if (!APIResource.class.isAssignableFrom(c)) {
            continue;
        }
        // Skip the APIResource itself
        if (APIResource.class == c) {
            continue;
        }
        classList.add(classInfo.load());
    }
    return classList;
}
Also used : ClassPath(com.google.common.reflect.ClassPath) APIResource(com.stripe.net.APIResource)

Aggregations

ClassPath (com.google.common.reflect.ClassPath)1 APIResource (com.stripe.net.APIResource)1