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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanfinal booleanIndicates whether some other object is "equal to" this one.first()Returns the value of thefirstrecord component.final inthashCode()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 therestrecord component.static <T> IdNonEmptyList<T> single(T x) Create a one-element list.intsize()toList()final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:
trueif 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 thefirstrecord component.- Returns:
- the value of the
firstrecord component
-
rest
Returns the value of therestrecord component.- Returns:
- the value of the
restrecord component
-