Module NewOCR

Interface ReflectionCacher

  • All Known Implementing Classes:
    ConfigReflectionCacher

    public interface ReflectionCacher
    A simple class to cache constructors from classes.
    Since:
    April 25, 2019
    • Method Summary

      Modifier and Type Method Description
      <T> java.util.Optional<java.lang.reflect.Constructor<T>> getOrLookupConstructor​(java.lang.Class<T> clazz, ReflexiveSupplier<java.lang.reflect.Constructor<T>> constructorGenerator)
      Gets a constructor from the internal cache from the given class, or generate one via constructorGenerator.
    • Method Detail

      • getOrLookupConstructor

        <T> java.util.Optional<java.lang.reflect.Constructor<T>> getOrLookupConstructor​(java.lang.Class<T> clazz,
                                                                                        ReflexiveSupplier<java.lang.reflect.Constructor<T>> constructorGenerator)
        Gets a constructor from the internal cache from the given class, or generate one via constructorGenerator. The generation of one from constructorGenerator then saves it in the local cache.
        Type Parameters:
        T - The class type
        Parameters:
        clazz - The class to generate or fetch the constructor from
        constructorGenerator - The supplier to make the constructor if one is not found
        Returns:
        The constructor, if found