Package com.io7m.idstore.model
Record Class IdNonEmptyList<T>
java.lang.Object
java.lang.Record
com.io7m.idstore.model.IdNonEmptyList<T>
- Type Parameters:
T
- The type of elements- Record Components:
first
- The first elementrest
- The rest of the elements
- All Implemented Interfaces:
Iterable<T>
A non-empty list.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
final boolean
Indicates whether some other object is "equal to" this one.first()
Returns the value of thefirst
record component.final int
hashCode()
Returns a hash code value for this object.iterator()
static <T> IdNonEmptyList
<T> The list as a non-empty list.rest()
Returns the value of therest
record component.static <T> IdNonEmptyList
<T> single
(T x) Create a one-element list.int
size()
toList()
final String
toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
IdNonEmptyList
A non-empty list.- Parameters:
first
- The first elementrest
- The rest of the elements
-
-
Method Details
-
single
Create a one-element list.- Type Parameters:
T
- The type of elements- Parameters:
x
- The element- Returns:
- The result list
-
toList
- Returns:
- This list as a plain immutable list
-
ofList
The list as a non-empty list.- Type Parameters:
T
- The type of elements- Parameters:
items
- The list elements- Returns:
- The list
- Throws:
IdValidityException
- On empty lists
-
contains
- Parameters:
email
- The email address- Returns:
true
if the list contains the given email
-
iterator
-
size
public int size()- Returns:
- The list size
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
first
Returns the value of thefirst
record component.- Returns:
- the value of the
first
record component
-
rest
Returns the value of therest
record component.- Returns:
- the value of the
rest
record component
-