Class Option.None<T>
java.lang.Object
cloud.opencode.base.functional.monad.Option.None<T>
- Type Parameters:
T- value type - 值类型
- All Implemented Interfaces:
Option<T>
None - Represents absence of value
None - 表示值缺失
- Since:
- JDK 25, opencode-base-functional V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
-
Nested Class Summary
Nested classes/interfaces inherited from interface Option
Option.None<T>, Option.Some<T> -
Method Summary
Modifier and TypeMethodDescriptionbooleanFilter the value with predicate 使用谓词过滤值<U> Option<U> Transform to another Option if Some 如果是 Some 则转换为另一个 Option<R> RFold this Option by applying one of two functions 通过应用两个函数之一来折叠此 Optionget()Get the value, throws if None 获取值,如果是 None 则抛出异常Get value or compute default if None 获取值或计算默认值(如果是 None)Get value or default if None 获取值或默认值(如果是 None)inthashCode()booleanisNone()Check if this is None 检查是否为 NonebooleanisSome()Check if this is Some 检查是否为 Some<U> Option<U> Transform the value if Some 如果是 Some 则转换值Execute action if None 如果是 None 则执行操作Return this or other Option if None 返回本 Option 或其他 Option(如果是 None)Return this or computed Option if None 返回本 Option 或计算的 Option(如果是 None)Execute action if Some 如果是 Some 则执行操作toEither(L left) Convert to Either (None becomes Left) 转换为 Either(None 变为 Left)Convert to Optional 转换为 OptionaltoString()
-
Method Details
-
isSome
-
isNone
-
get
-
map
Description copied from interface:OptionTransform the value if Some 如果是 Some 则转换值 -
flatMap
Description copied from interface:OptionTransform to another Option if Some 如果是 Some 则转换为另一个 Option -
filter
-
fold
Description copied from interface:OptionFold this Option by applying one of two functions 通过应用两个函数之一来折叠此 OptionThis is the catamorphism for Option - handles both cases symmetrically.
这是 Option 的态射 - 对称地处理两种情况。
Example | 示例:
String result = option.fold( () -> "No value", // None case value -> "Got: " + value // Some case ); -
getOrElse
-
getOrElse
-
orElse
-
orElse
Description copied from interface:OptionReturn this or computed Option if None 返回本 Option 或计算的 Option(如果是 None) -
toOptional
-
toEither
Description copied from interface:OptionConvert to Either (None becomes Left) 转换为 Either(None 变为 Left) -
peek
-
onNone
-
equals
-
hashCode
-
toString
-