Class CachingFactory<CreatedT>

  • All Implemented Interfaces:
    java.io.Serializable, Factory<CreatedT>

    public class CachingFactory<CreatedT>
    extends java.lang.Object
    implements Factory<CreatedT>
    A wrapper around a Factory that assumes the schema parameter never changes.

    Factory objects take the schema as a parameter, as often the returned type varies by schema (e.g. sometimes the returned-type is a list that must be in schema-field order). However in many cases it's known by the caller that the schema parameter is always the same across all calls to create. In these cases we want to save the cost of Schema comparison (which can be significant for larger schemas) on each lookup. This wrapper caches the value returned by the inner factory, so the schema comparison only need happen on the first lookup.

    See Also:
    Serialized Form
    • Constructor Detail

      • CachingFactory

        public CachingFactory​(Factory<CreatedT> innerFactory)
    • Method Detail

      • equals

        public boolean equals​(@Nullable java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object