All Downloads are FREE. Search and download functionalities are using the official Maven repository.

info.javaspec.spec.InnerClassFactory Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
package info.javaspec.spec;

import java.lang.reflect.Constructor;

final class InnerClassFactory extends ClassFactory {
  private final Class enclosingClass;
  private final Object enclosingObject;

  public InnerClassFactory(Class enclosingClass, Object enclosingObject) {
    this.enclosingClass = enclosingClass;
    this.enclosingObject = enclosingObject;
  }

  @Override
  protected Constructor getConstructor(Class innerClass) throws NoSuchMethodException {
    return innerClass.getDeclaredConstructor(enclosingClass);
  }

  @Override
  protected Object makeInstance(Constructor constructor) throws ReflectiveOperationException {
    return constructor.newInstance(enclosingObject);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy