Package software.kes.collectionviews
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>
ASet
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
, andImmutableSet
.
-
-
Method Summary
All Methods Static Methods Instance Methods Default Methods Modifier and Type Method Description default ImmutableNonEmptySet<A>
distinct()
Since aImmutableNonEmptySet
already contains only distinct values, this method always returns itself.static <A> ImmutableNonEmptySet<A>
of(A first, A... more)
Creates aImmutableNonEmptySet
with the given elements.default ImmutableNonEmptySet<A>
toImmutable()
Returns anImmutableNonEmptySet
containing the same elements as this one.default com.jnape.palatable.lambda.adt.Maybe<? extends ImmutableNonEmptySet<A>>
toNonEmpty()
Attempts to convert thisImmutableSet
to anImmutableNonEmptySet
.default ImmutableNonEmptySet<A>
toNonEmptyOrThrow()
Attempts to convert thisImmutableSet
to aImmutableNonEmptySet
.-
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 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 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
-
Methods inherited from interface software.kes.collectionviews.NonEmptySet
isEmpty
-
-
-
-
Method Detail
-
distinct
default ImmutableNonEmptySet<A> distinct()
Since aImmutableNonEmptySet
already contains only distinct values, this method always returns itself.- Specified by:
distinct
in interfacesoftware.kes.enhancediterables.FiniteIterable<A>
- Specified by:
distinct
in interfacesoftware.kes.enhancediterables.ImmutableFiniteIterable<A>
- Specified by:
distinct
in interfacesoftware.kes.enhancediterables.ImmutableNonEmptyFiniteIterable<A>
- Specified by:
distinct
in interfaceImmutableSet<A>
- Specified by:
distinct
in interfacesoftware.kes.enhancediterables.NonEmptyFiniteIterable<A>
- Specified by:
distinct
in interfaceNonEmptySet<A>
- Specified by:
distinct
in interfaceSet<A>
- Returns:
- itself
-
toImmutable
default ImmutableNonEmptySet<A> toImmutable()
Returns anImmutableNonEmptySet
containing the same elements as this one.Since this is an
ImmutableNonEmptySet
already, this method simply returns itself.- Specified by:
toImmutable
in interfaceImmutableSet<A>
- Specified by:
toImmutable
in interfaceNonEmptySet<A>
- Specified by:
toImmutable
in interfaceSet<A>
- Returns:
- itself
-
toNonEmpty
default com.jnape.palatable.lambda.adt.Maybe<? extends ImmutableNonEmptySet<A>> toNonEmpty()
Attempts to convert thisImmutableSet
to anImmutableNonEmptySet
.Since this will always be successful for
ImmutableNonEmptySet
s, this method always returns itself wrapped in aMaybe.just(A)
.Does not make copies of any underlying data structures.
- Specified by:
toNonEmpty
in interfacesoftware.kes.enhancediterables.EnhancedIterable<A>
- Specified by:
toNonEmpty
in interfacesoftware.kes.enhancediterables.FiniteIterable<A>
- Specified by:
toNonEmpty
in interfacesoftware.kes.enhancediterables.ImmutableFiniteIterable<A>
- Specified by:
toNonEmpty
in interfacesoftware.kes.enhancediterables.ImmutableIterable<A>
- Specified by:
toNonEmpty
in interfacesoftware.kes.enhancediterables.ImmutableNonEmptyFiniteIterable<A>
- Specified by:
toNonEmpty
in interfacesoftware.kes.enhancediterables.ImmutableNonEmptyIterable<A>
- Specified by:
toNonEmpty
in interfaceImmutableSet<A>
- Specified by:
toNonEmpty
in interfacesoftware.kes.enhancediterables.NonEmptyFiniteIterable<A>
- Specified by:
toNonEmpty
in interfacesoftware.kes.enhancediterables.NonEmptyIterable<A>
- Specified by:
toNonEmpty
in interfaceNonEmptySet<A>
- Specified by:
toNonEmpty
in interfaceSet<A>
- Returns:
- this
ImmutableNonEmptySet
wrapped in aMaybe.just(A)
-
toNonEmptyOrThrow
default ImmutableNonEmptySet<A> toNonEmptyOrThrow()
Attempts to convert thisImmutableSet
to aImmutableNonEmptySet
.Since this will always be successful for
ImmutableNonEmptySet
s, this method always returns itself.Does not make copies of any underlying data structures.
- Specified by:
toNonEmptyOrThrow
in interfaceImmutableSet<A>
- Specified by:
toNonEmptyOrThrow
in interfaceNonEmptySet<A>
- Specified by:
toNonEmptyOrThrow
in interfaceSet<A>
- Returns:
- this
ImmutableNonEmptySet
-
of
@SafeVarargs static <A> ImmutableNonEmptySet<A> of(A first, A... more)
Creates aImmutableNonEmptySet
with the given elements.- Type Parameters:
A
- the element type- Parameters:
first
- the first elementmore
- the remaining elements- Returns:
- an
ImmutableNonEmptySet<A>
-
-