Class Resource<T>


  • public final class Resource<T>
    extends java.lang.Object
    Base state model object.

    This state can either be successful or not. In either case, it must be complete to represent these states.

    • Method Detail

      • forSuccess

        @NonNull
        public static <T> Resource<T> forSuccess​(@NonNull
                                                 T value)
        Creates a successful resource containing a value.
      • forFailure

        @NonNull
        public static <T> Resource<T> forFailure​(@NonNull
                                                 java.lang.Exception e)
        Creates a failed resource with an exception.
      • forLoading

        @NonNull
        public static <T> Resource<T> forLoading()
        Creates a resource in the loading state, without a value or an exception.
      • getState

        @NonNull
        public State getState()
      • getException

        @Nullable
        public final java.lang.Exception getException()
      • getValue

        @Nullable
        public T getValue()
      • isUsed

        public boolean isUsed()
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

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