Interface ImmutableNonEmptySet<A>

  • Type Parameters:
    A - the element type
    All Superinterfaces:
    software.kes.enhancediterables.EnhancedIterable<A>, software.kes.enhancediterables.FiniteIterable<A>, com.jnape.palatable.lambda.functor.Functor<A,​software.kes.enhancediterables.EnhancedIterable<?>>, Immutable, software.kes.enhancediterables.ImmutableFiniteIterable<A>, software.kes.enhancediterables.ImmutableIterable<A>, software.kes.enhancediterables.ImmutableNonEmptyFiniteIterable<A>, software.kes.enhancediterables.ImmutableNonEmptyIterable<A>, ImmutableSet<A>, java.lang.Iterable<A>, software.kes.enhancediterables.NonEmptyFiniteIterable<A>, software.kes.enhancediterables.NonEmptyIterable<A>, NonEmptySet<A>, Set<A>

    public interface ImmutableNonEmptySet<A>
    extends NonEmptySet<A>, ImmutableSet<A>, software.kes.enhancediterables.ImmutableNonEmptyFiniteIterable<A>
    A Set that is guaranteed at compile-time to be non-empty and safe from mutation anywhere. In other words, it owns the sole reference to the underlying collection.

    Provides all the guarantees of Set, NonEmptySet, and ImmutableSet.

    • Method Summary

      All Methods Static Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default ImmutableNonEmptySet<A> distinct()
      Since a ImmutableNonEmptySet already contains only distinct values, this method always returns itself.
      static <A> ImmutableNonEmptySet<A> of​(A first, A... more)
      Creates a ImmutableNonEmptySet with the given elements.
      default ImmutableNonEmptySet<A> toImmutable()
      Returns an ImmutableNonEmptySet containing the same elements as this one.
      default com.jnape.palatable.lambda.adt.Maybe<? extends ImmutableNonEmptySet<A>> toNonEmpty()
      Attempts to convert this ImmutableSet to an ImmutableNonEmptySet.
      default ImmutableNonEmptySet<A> toNonEmptyOrThrow()
      Attempts to convert this ImmutableSet to a ImmutableNonEmptySet.
      • Methods inherited from interface software.kes.enhancediterables.EnhancedIterable

        concat, toArray, toCollection, zipWith, zipWith
      • Methods inherited from interface software.kes.enhancediterables.FiniteIterable

        append, concat, cross, cross, drop, dropWhile, filter, foldLeft, foldRight, partition, prepend, slide, span, tails, takeWhile, zipWith
      • Methods inherited from interface com.jnape.palatable.lambda.functor.Functor

        coerce
      • Methods inherited from interface software.kes.enhancediterables.ImmutableFiniteIterable

        append, concat, cross, drop, dropWhile, filter, inits, partition, slide, span, tails, takeWhile, zipWith
      • Methods inherited from interface software.kes.enhancediterables.ImmutableIterable

        concat, take, zipWith
      • Methods inherited from interface software.kes.enhancediterables.ImmutableNonEmptyFiniteIterable

        concat, cross, cycle, fmap, init, intersperse, magnetizeBy, prepend, prependAll, reverse, tail, toFinite, zipWith
      • Methods inherited from interface software.kes.enhancediterables.ImmutableNonEmptyIterable

        concat, zipWith
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
      • Methods inherited from interface software.kes.enhancediterables.NonEmptyFiniteIterable

        concat, concat, cross, cycle, fmap, intersperse, last, magnetizeBy, prependAll, reduceLeft, reduceRight, reverse, tail, toFinite, zipWith
      • Methods inherited from interface software.kes.enhancediterables.NonEmptyIterable

        concat, head, iterator, zipWith
    • Method Detail

      • distinct

        default ImmutableNonEmptySet<A> distinct()
        Since a ImmutableNonEmptySet already contains only distinct values, this method always returns itself.
        Specified by:
        distinct in interface software.kes.enhancediterables.FiniteIterable<A>
        Specified by:
        distinct in interface software.kes.enhancediterables.ImmutableFiniteIterable<A>
        Specified by:
        distinct in interface software.kes.enhancediterables.ImmutableNonEmptyFiniteIterable<A>
        Specified by:
        distinct in interface ImmutableSet<A>
        Specified by:
        distinct in interface software.kes.enhancediterables.NonEmptyFiniteIterable<A>
        Specified by:
        distinct in interface NonEmptySet<A>
        Specified by:
        distinct in interface Set<A>
        Returns:
        itself
      • toNonEmpty

        default com.jnape.palatable.lambda.adt.Maybe<? extends ImmutableNonEmptySet<A>> toNonEmpty()
        Attempts to convert this ImmutableSet to an ImmutableNonEmptySet.

        Since this will always be successful for ImmutableNonEmptySets, this method always returns itself wrapped in a Maybe.just(A).

        Does not make copies of any underlying data structures.

        Specified by:
        toNonEmpty in interface software.kes.enhancediterables.EnhancedIterable<A>
        Specified by:
        toNonEmpty in interface software.kes.enhancediterables.FiniteIterable<A>
        Specified by:
        toNonEmpty in interface software.kes.enhancediterables.ImmutableFiniteIterable<A>
        Specified by:
        toNonEmpty in interface software.kes.enhancediterables.ImmutableIterable<A>
        Specified by:
        toNonEmpty in interface software.kes.enhancediterables.ImmutableNonEmptyFiniteIterable<A>
        Specified by:
        toNonEmpty in interface software.kes.enhancediterables.ImmutableNonEmptyIterable<A>
        Specified by:
        toNonEmpty in interface ImmutableSet<A>
        Specified by:
        toNonEmpty in interface software.kes.enhancediterables.NonEmptyFiniteIterable<A>
        Specified by:
        toNonEmpty in interface software.kes.enhancediterables.NonEmptyIterable<A>
        Specified by:
        toNonEmpty in interface NonEmptySet<A>
        Specified by:
        toNonEmpty in interface Set<A>
        Returns:
        this ImmutableNonEmptySet wrapped in a Maybe.just(A)
      • of

        @SafeVarargs
        static <A> ImmutableNonEmptySet<A> of​(A first,
                                              A... more)
        Creates a ImmutableNonEmptySet with the given elements.
        Type Parameters:
        A - the element type
        Parameters:
        first - the first element
        more - the remaining elements
        Returns:
        an ImmutableNonEmptySet<A>