Class Ribbon<T>

java.lang.Object
org.proforma.variability.util.Ribbon<T>
Type Parameters:
T -
All Implemented Interfaces:
Consumer<T>, Supplier<T>

public class Ribbon<T> extends Object implements Supplier<T>, Consumer<T>

A Ribbon connects a data object of type T with a supplier and a consumer. A client of the ribbon can read the data object via the supplier and write or replace the data object via the supplier.

Example:

   java.awt.Point p= new java.awt.Point(4,5);
   Ribbon rx= new Ribbon<>(() -> p.x, newx -> p.x= newx);
 

The previous example allows a client to read and replace the x coordinate of p, without knowing about the type of the whole object p.

The name "ribbon" comes from looking at it as a thing that is start and ending in itself, just like a printer ribbon.

  • Constructor Details

  • Method Details

    • getSource

      public Supplier<T> getSource()
    • setSource

      public void setSource(Supplier<T> source)
    • getTarget

      public Consumer<T> getTarget()
    • setTarget

      public void setTarget(Consumer<T> target)
    • getHint

      public String getHint()
    • setHint

      public void setHint(String hint)
    • accept

      public void accept(T t)
      Specified by:
      accept in interface Consumer<T>
    • get

      public T get()
      Specified by:
      get in interface Supplier<T>