Package cs2030s.fp

Class Lazy<T>

  • All Implemented Interfaces:
    Immutatorable<T>
    Direct Known Subclasses:
    Memo

    public class Lazy<T>
    extends java.lang.Object
    implements Immutatorable<T>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private Constant<? extends T> init  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Lazy​(Constant<? extends T> c)  
    • Field Detail

    • Constructor Detail

      • Lazy

        protected Lazy​(Constant<? extends T> c)
    • Method Detail

      • get

        public T get()
      • from

        public static <T> Lazy<T> from​(T v)
      • from

        public static <T> Lazy<T> from​(Constant<? extends T> v)
      • transform

        public <R> Lazy<R> transform​(Immutator<? extends R,​? super T> f)
        Description copied from interface: Immutatorable
        The method to produce another container with immutated element.
        Specified by:
        transform in interface Immutatorable<T>
        Type Parameters:
        R - the return type
        Parameters:
        f - The immutator.
        Returns:
        A new container containing the immutated element.
      • next

        public <R> Lazy<R> next​(Immutator<? extends Lazy<? extends R>,​? super T> f)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object