Module org.jhotdraw8.icollection
Record Class Option.None<T>
java.lang.Object
java.lang.Record
org.jhotdraw8.icollection.impl.redblack.Option.None<T>
- All Implemented Interfaces:
Iterable<T>,Option<T>,ReadOnlyCollection<T>
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jhotdraw8.icollection.impl.redblack.Option
Option.None<T>, Option.Some<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif this collection contains the specified object.final booleanIndicates whether some other object is "equal to" this one.get()Gets the value if this is aSomeor throws if this is aNone.final inthashCode()Returns a hash code value for this object.booleanisEmpty()Returns true, if this isNone, otherwise false, if this isSome.iterator()Returns an iterator over the elements in this collection.Returns thisOptionif it is nonempty, otherwise return the alternative.orNull()Returns thisOptionif this is defined, ornullif it is empty.orThrow()Returns thisOptionif this is defined, or throws aNoSuchElementExceptionif it is empty.intsize()Returns the size of the collection.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, spliteratorMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlyCollection
asCollection, characteristics, containsAll, stream, toArray, toArray
-
Constructor Details
-
None
public None()Creates an instance of aNonerecord class.
-
-
Method Details
-
size
public int size()Description copied from interface:ReadOnlyCollectionReturns the size of the collection.- Specified by:
sizein interfaceReadOnlyCollection<T>- Returns:
- the size
-
isEmpty
public boolean isEmpty()Description copied from interface:OptionReturns true, if this isNone, otherwise false, if this isSome.// Prints "false" System.out.println(Option.of(10).isEmpty()); // Prints "true" System.out.println(Option.none().isEmpty()); -
contains
Description copied from interface:ReadOnlyCollectionReturnstrueif this collection contains the specified object.- Specified by:
containsin interfaceReadOnlyCollection<T>- Parameters:
o- an object- Returns:
trueif this collection contains the specified object
-
iterator
Description copied from interface:ReadOnlyCollectionReturns an iterator over the elements in this collection. -
orElse
Description copied from interface:OptionReturns thisOptionif it is nonempty, otherwise return the alternative.Option<String> other = Option.of("Other"); // = Some("Hello World") Option.of("Hello World").orElse(other); // = Some("Other") Option.none().orElse(other); -
get
Description copied from interface:OptionGets the value if this is aSomeor throws if this is aNone.// Prints "57" System.out.println(Option.of(57).get()); // Throws a NoSuchElementException Option.none().get(); -
orNull
Description copied from interface:OptionReturns thisOptionif this is defined, ornullif it is empty.// = Some("Hello World") Option.of("Hello World").orNull(); // = null Option.none().orNull(); -
orThrow
Description copied from interface:OptionReturns thisOptionif this is defined, or throws aNoSuchElementExceptionif it is empty.// = Some("Hello World") Option.of("Hello World").orThrow(); // = null Option.none().orThrow(); -
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.
-