Class Proxies

java.lang.Object
org.qubership.atp.dataset.db.utils.Proxies

public class Proxies extends Object
  • Constructor Details

    • Proxies

      public Proxies()
  • Method Details

    • withId

      public static <T extends Identified, IdT> T withId(@Nonnull Class<T> type, @Nonnull IdT id, @Nonnull Function<IdT,? extends T> sourceFunc)
      Proxy which obtains a real object using id and sourceFunc on access. Methods Object.equals(Object), Object.hashCode(), Identified.getId() do not trigger the sourceFunc.
      Type Parameters:
      T - target
      Parameters:
      type - target interface
      id - identified object id
      sourceFunc - explains how to obtain a real instance, should not return null ever
      Returns:
      proxy
    • list

      public static <T> List<T> list(@Nonnull Supplier<List<T>> sup)
      Wraps a list into proxy. See base(Class, Supplier)
    • base

      public static <T> T base(@Nonnull Class<T> type, @Nonnull Supplier<? extends T> sup)
      Wraps an supplier into object type of T. Supplier is triggered once on access to object methods.
      Type Parameters:
      T - target
      Parameters:
      type - target object type
      sup - Supplier should not return null ever
      Returns:
      proxy