Package com.github.skopylov58.functional
Record Class Option.Some<T>
java.lang.Object
java.lang.Record
com.github.skopylov58.functional.Option.Some<T>
- All Implemented Interfaces:
Monad<T>,MonadAccessor<T>,Option<T>
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.github.skopylov58.functional.Option
Option.None<T>, Option.Some<T> -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<R> Monad<R>final booleanIndicates whether some other object is "equal to" this one.<R> Option<R>getOrDefault(T defaultValue) final inthashCode()Returns a hash code value for this object.<R> Option<R>optional()stream()t()Returns the value of thetrecord component.toString()Returns a string representation of this record class.
-
Constructor Details
-
Some
Creates an instance of aSomerecord class.- Parameters:
t- the value for thetrecord component
-
-
Method Details
-
map
-
flatMap
-
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. -
bind
-
getOrDefault
- Specified by:
getOrDefaultin interfaceMonadAccessor<T>
-
stream
- Specified by:
streamin interfaceMonadAccessor<T>
-
optional
- Specified by:
optionalin interfaceMonadAccessor<T>
-
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). -
t
Returns the value of thetrecord component.- Returns:
- the value of the
trecord component
-