Class Static

java.lang.Object
net.hydromatic.morel.util.Static

public class Static extends Object
Utilities.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final boolean
    Whether to skip built-in functions.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <E> List<E>
    append(List<E> list, E e)
    Returns a list with one element appended.
    private static boolean
    getBooleanProperty(String prop, boolean defaultVal)
    Returns the value of a system property, converted into a boolean value.
    static <E> List<E>
    intersect(List<E> list0, Iterable<? extends E> list1)
     
    static <E> List<E>
    minus(List<E> list, E e)
    Removes all occurrences of an element from a list.
    static int
    Next power of two.
    static <E> List<E>
    plus(E e, List<E> list)
    Prepends an element to a list.
    static <K, V> Map<K,V>
    plus(Map<K,V> map, K k, V v)
    Adds an element to a map.
    static <K extends Comparable<K>, V>
    SortedMap<K,V>
    plus(SortedMap<K,V> map, K k, V v)
    Adds an element to a sorted map.
    static <E> boolean
    shorterThan(Iterable<E> iterable, int n)
    Returns whether an Iterable has fewer than n elements.
    static <E> List<E>
    skip(int count, List<E> list)
    Returns all but the first count elements of a list.
    static <E> List<E>
    skip(List<E> list)
    Returns all but the first element of a list.
    static String
    Flushes a builder and returns its contents.
    static <T> Collector<T,com.google.common.collect.ImmutableList.Builder<T>,com.google.common.collect.ImmutableList<T>>
    Returns a Collector that accumulates the input elements into a Guava ImmutableList via a ImmutableList.Builder.
    static <E, T> Iterable<T>
    transform(Iterable<? extends E> elements, Function<E,T> mapper)
    Lazily transforms an Iterable, applying a mapping function to each element.
    static <E, T> List<T>
    transform(List<? extends E> elements, Function<E,T> mapper)
    Lazily transforms a list, applying a mapping function to each element.
    static <E, T> com.google.common.collect.ImmutableList<T>
    transformEager(Iterable<? extends E> elements, Function<E,T> mapper)
    Eagerly converts an Iterable to an ImmutableList, applying a mapping function to each element.
    static <E, T> com.google.common.collect.ImmutableList<T>
    transformEager(List<? extends E> elements, Function<E,T> mapper)
    Eagerly converts a List to an ImmutableList, applying a mapping function to each element.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SKIP

      public static final boolean SKIP
      Whether to skip built-in functions.

      To skip built-in functions, add "-DskipMorelBuiltIns" java's command-line arguments.

  • Constructor Details

    • Static

      private Static()
  • Method Details

    • getBooleanProperty

      private static boolean getBooleanProperty(String prop, boolean defaultVal)
      Returns the value of a system property, converted into a boolean value.

      Values "", "true", "TRUE" and "1" are treated as true; "false", "FALSE" and "0" treated as false; for null and other values, returns defaultVal.

    • toImmutableList

      public static <T> Collector<T,com.google.common.collect.ImmutableList.Builder<T>,com.google.common.collect.ImmutableList<T>> toImmutableList()
      Returns a Collector that accumulates the input elements into a Guava ImmutableList via a ImmutableList.Builder.

      It will be obsolete when we move to Guava 21.0, which has ImmutableList.toImmutableList().

      Type Parameters:
      T - Type of the input elements
      Returns:
      a Collector that collects all the input elements into an ImmutableList, in encounter order
    • shorterThan

      public static <E> boolean shorterThan(Iterable<E> iterable, int n)
      Returns whether an Iterable has fewer than n elements.
      Type Parameters:
      E - Element type
    • skip

      public static <E> List<E> skip(List<E> list)
      Returns all but the first element of a list.
    • skip

      public static <E> List<E> skip(int count, List<E> list)
      Returns all but the first count elements of a list.
    • append

      public static <E> List<E> append(List<E> list, E e)
      Returns a list with one element appended.
      See Also:
    • plus

      public static <E> List<E> plus(E e, List<E> list)
      Prepends an element to a list.
    • minus

      public static <E> List<E> minus(List<E> list, E e)
      Removes all occurrences of an element from a list.
    • plus

      public static <K, V> Map<K,V> plus(Map<K,V> map, K k, V v)
      Adds an element to a map.
    • plus

      public static <K extends Comparable<K>, V> SortedMap<K,V> plus(SortedMap<K,V> map, K k, V v)
      Adds an element to a sorted map.
    • nextPowerOfTwo

      public static int nextPowerOfTwo(int n)
      Next power of two.
    • transform

      public static <E, T> List<T> transform(List<? extends E> elements, Function<E,T> mapper)
      Lazily transforms a list, applying a mapping function to each element.
    • transform

      public static <E, T> Iterable<T> transform(Iterable<? extends E> elements, Function<E,T> mapper)
      Lazily transforms an Iterable, applying a mapping function to each element.
    • transformEager

      public static <E, T> com.google.common.collect.ImmutableList<T> transformEager(Iterable<? extends E> elements, Function<E,T> mapper)
      Eagerly converts an Iterable to an ImmutableList, applying a mapping function to each element.
    • transformEager

      public static <E, T> com.google.common.collect.ImmutableList<T> transformEager(List<? extends E> elements, Function<E,T> mapper)
      Eagerly converts a List to an ImmutableList, applying a mapping function to each element.
    • intersect

      public static <E> List<E> intersect(List<E> list0, Iterable<? extends E> list1)
    • str

      public static String str(StringBuilder b)
      Flushes a builder and returns its contents.