Class Sugar


  • public class Sugar
    extends Object
    Simple syntax sugar/shortener
    • Constructor Detail

      • Sugar

        public Sugar()
    • Method Detail

      • optional

        public static <T> Optional<T> optional​(T value)
        Shortens the Optional.ofNullable(..) syntax.
      • fallback

        public <T> T fallback​(T val,
                              T fallback)
        Returns the given value, or the fallback if the value is null.
      • not

        public static <T> Predicate<T> not​(Predicate<T> t)
        Negates the given Predicate
      • cast

        public static <T> T cast​(Object x)
        Casts an object by type inference. see also http://weblogs.java.net/blog/emcmanus/archive/2007/03/getting_rid_of.html See Generics
        Parameters:
        x - Object that will be casted