Class Interfaces

java.lang.Object
org.soliscode.test.interfaces.Interfaces

public final class Interfaces extends Object
Utility class that helps create interface-narrowing views on objects.
Since:
1.0
Author:
evanbergstrom
  • Method Details

    • narrowToObject

      public static ObjectOnly narrowToObject(@NotNull @NotNull Object obj)
      Wraps the object so that only the methods in the Object interface are available.
      Parameters:
      obj - the object to wrap.
      Returns:
      the wrapped object.
    • narrowToNumber

      public static NumberOnly narrowToNumber(Number n)
      Wraps the object so that only the methods in the Number interface are available.
      Parameters:
      n - the number to wrap.
      Returns:
      the wrapped number.
    • narrowToIterable

      public static <E> IterableOnly<E> narrowToIterable(Iterable<E> i)
      Wraps the object so that only the methods in the Iterable interface are available.
      Type Parameters:
      E - the element type for the iterable.
      Parameters:
      i - the iterable to wrap
      Returns:
      the wrapped iterable.
    • narrowToCollection

      public static <E> CollectionOnly<E> narrowToCollection(Collection<E> i)
      Wraps the object so that only the methods in the Collection interface are available.
      Type Parameters:
      E - the element type for the iterable.
      Parameters:
      i - the iterable to wrap
      Returns:
      the wrapped iterable.