final case class JsonSome[+A](x: A) extends JsonOption[A] with Product with Serializable
Class Some[A]
represents existing values of type A
.
- Alphabetic
- By Inheritance
- JsonSome
- Serializable
- Product
- Equals
- JsonOption
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new JsonSome(x: A)
Type Members
- class WithFilter extends AnyRef
We need a whole WithFilter class to honor the "doesn't create a new collection" contract even though it seems unlikely to matter much in a collection with max size 1.
We need a whole WithFilter class to honor the "doesn't create a new collection" contract even though it seems unlikely to matter much in a collection with max size 1.
- Definition Classes
- JsonOption
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- final def collect[B](pf: PartialFunction[A, B]): JsonOption[B]
Returns a JsonSome containing the result of applying
pf
to this JsonOption's contained value, if this option is nonempty andpf
is defined for that value.Returns a JsonSome containing the result of applying
pf
to this JsonOption's contained value, if this option is nonempty andpf
is defined for that value. Returns JsonAbsent otherwise.- pf
the partial function.
- returns
the result of applying
pf
to this JsonOption's value (if possible), or JsonAbsent.
- Definition Classes
- JsonOption
- Annotations
- @inline()
// Returns Some(HTTP) because the partial function covers the case. Some("http") collect {case "http" => "HTTP"} // Returns None because the partial function doesn't cover the case. Some("ftp") collect {case "http" => "HTTP"} // Returns None because None is passed to the collect method. None collect {case value => value}
Example: - final def contains[A1 >: A](elem: A1): Boolean
Tests whether the option contains a given value as an element.
Tests whether the option contains a given value as an element.
- elem
the element to test.
- returns
true
if the option has an element that is equal (as determined by==
) toelem
,false
otherwise.
- Definition Classes
- JsonOption
// Returns true because Some instance contains string "something" which equals "something". Some("something") contains "something" // Returns false because "something" != "anything". Some("something") contains "anything" // Returns false when method called on None. None contains "anything"
Example: - final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def exists(p: (A) => Boolean): Boolean
Returns true if this option is nonempty and the predicate
p
returns true when applied to this JsonOption's value.Returns true if this option is nonempty and the predicate
p
returns true when applied to this JsonOption's value. Otherwise, returns false.- p
the predicate to test
- Definition Classes
- JsonOption
- Annotations
- @inline()
- final def filter(p: (A) => Boolean): JsonOption[A]
Returns this JsonOption if it is nonempty and applying the predicate
p
to this JsonOption's value returns true.Returns this JsonOption if it is nonempty and applying the predicate
p
to this JsonOption's value returns true. Otherwise, return JsonAbsent.- p
the predicate used for testing.
- Definition Classes
- JsonOption
- Annotations
- @inline()
- final def filterNot(p: (A) => Boolean): JsonOption[A]
Returns this JsonOption if it is nonempty and applying the predicate
p
to this JsonOption's value returns false.Returns this JsonOption if it is nonempty and applying the predicate
p
to this JsonOption's value returns false. Otherwise, return JsonAbsent.- p
the predicate used for testing.
- Definition Classes
- JsonOption
- Annotations
- @inline()
- final def flatMap[B](f: (A) => JsonOption[B]): JsonOption[B]
Returns the result of applying
f
to this JsonOption's value if this JsonOption is nonempty.Returns the result of applying
f
to this JsonOption's value if this JsonOption is nonempty. Returns JsonAbsent if this JsonOption is empty. Slightly different frommap
in thatf
is expected to return an JsonOption (which could be JsonAbsent).- f
the function to apply
- Definition Classes
- JsonOption
- Annotations
- @inline()
- See also
map
foreach
- def flatten[B](implicit ev: <:<[A, JsonOption[B]]): JsonOption[B]
- Definition Classes
- JsonOption
- final def fold[B](ifEmpty: => B)(f: (A) => B): B
Returns the result of applying
f
to this JsonOption's value if the JsonOption is nonempty.Returns the result of applying
f
to this JsonOption's value if the JsonOption is nonempty. Otherwise, evaluates expressionifEmpty
.- ifEmpty
the expression to evaluate if empty.
- f
the function to apply if nonempty.
- Definition Classes
- JsonOption
- Annotations
- @inline()
- Note
This is equivalent to
JsonOption map f getOrElse ifEmpty
.
- final def forall(p: (A) => Boolean): Boolean
Returns true if this option is empty or the predicate
p
returns true when applied to this JsonOption's value.Returns true if this option is empty or the predicate
p
returns true when applied to this JsonOption's value.- p
the predicate to test
- Definition Classes
- JsonOption
- Annotations
- @inline()
- final def foreach[U](f: (A) => U): Unit
Apply the given procedure
f
to the option's value, if it is nonempty.Apply the given procedure
f
to the option's value, if it is nonempty. Otherwise, do nothing.- f
the procedure to apply.
- Definition Classes
- JsonOption
- Annotations
- @inline()
- See also
map
flatMap
- def get: A
Returns the maybe's value.
Returns the maybe's value.
- Definition Classes
- JsonSome → JsonOption
- Exceptions thrown
java.util.NoSuchElementException
if the maybe is empty- Note
The maybe must be nonEmpty
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- final def getOrElse[B >: A](default: => B): B
Returns the maybe's value if the maybe is nonempty, otherwise return the result of evaluating
default
.Returns the maybe's value if the maybe is nonempty, otherwise return the result of evaluating
default
.- default
the default expression.
- Definition Classes
- JsonOption
- Annotations
- @inline()
- def isAbsent: Boolean
Returns true if maybe is nothing
Returns true if maybe is nothing
- Definition Classes
- JsonSome → JsonOption
- def isDefined: Boolean
Returns true if maybe is instance of just
Returns true if maybe is instance of just
- Definition Classes
- JsonOption
- def isEmpty: Boolean
Returns true if maybe is nothing or null
Returns true if maybe is nothing or null
- Definition Classes
- JsonSome → JsonOption
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def iterator: Iterator[A]
Returns a singleton iterator returning the JsonOption's value if it is nonempty, or an empty iterator if the option is empty.
Returns a singleton iterator returning the JsonOption's value if it is nonempty, or an empty iterator if the option is empty.
- Definition Classes
- JsonOption
- final def map[B](f: (A) => B): JsonOption[B]
Returns a JsonSome containing the result of applying
f
to this JsonOption's value if this JsonOption is nonempty.Returns a JsonSome containing the result of applying
f
to this JsonOption's value if this JsonOption is nonempty. Otherwise return JsonAbsent.- f
the function to apply
- Definition Classes
- JsonOption
- Annotations
- @inline()
- Note
This is similar to
flatMap
except here,f
does not need to wrap its result in an JsonOption.- See also
flatMap
foreach
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def nonEmpty: Boolean
Returns false if the option is JsonAbsent, true otherwise.
Returns false if the option is JsonAbsent, true otherwise.
- Definition Classes
- JsonOption
- Note
Implemented here to avoid the implicit conversion to Iterable.
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def orElse[B >: A](alternative: => JsonOption[B]): JsonOption[B]
Returns this JsonOption if it is nonempty, otherwise return the result of evaluating
alternative
.Returns this JsonOption if it is nonempty, otherwise return the result of evaluating
alternative
.- alternative
the alternative expression.
- Definition Classes
- JsonOption
- Annotations
- @inline()
- final def orNull[A1 >: A](implicit ev: <:<[Null, A1]): A1
Returns the option's value if it is nonempty, or
null
if it is empty.Returns the option's value if it is nonempty, or
null
if it is empty. Although the use of null is discouraged, code written to use JsonOption must often interface with code that expects and returns nulls.- Definition Classes
- JsonOption
- Annotations
- @inline()
val initialText: Option[String] = getInitialText val textField = new JComponent(initialText.orNull,20)
Example: - def productElementNames: Iterator[String]
- Definition Classes
- Product
- def someOrElse[B >: A](x: Option[B]): Option[B]
Helper function to .orElse JsonSome.
Helper function to .orElse JsonSome. Result is None for JsonNull but for JsonAbsent x param is returned
- Definition Classes
- JsonOption
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- final def toLeft[X](right: => X): Either[A, X]
Returns a scala.util.Right containing the given argument
right
if this is empty, or a scala.util.Left containing this JsonOption's value if this JsonOption is nonempty.Returns a scala.util.Right containing the given argument
right
if this is empty, or a scala.util.Left containing this JsonOption's value if this JsonOption is nonempty.- right
the expression to evaluate and return if this is empty
- Definition Classes
- JsonOption
- Annotations
- @SuppressWarnings() @inline()
- See also
toRight
- def toList: List[A]
Returns a singleton list containing the JsonOption's value if it is nonempty, or the empty list if the JsonOption is empty.
Returns a singleton list containing the JsonOption's value if it is nonempty, or the empty list if the JsonOption is empty.
- Definition Classes
- JsonOption
- def toOption: Option[A]
Turns this JsonOption into scala Option
Turns this JsonOption into scala Option
- Definition Classes
- JsonSome → JsonOption
- final def toRight[X](left: => X): Either[X, A]
Returns a scala.util.Left containing the given argument
left
if this JsonOption is empty, or a scala.util.Right containing this JsonOption's value if this is nonempty.Returns a scala.util.Left containing the given argument
left
if this JsonOption is empty, or a scala.util.Right containing this JsonOption's value if this is nonempty.- left
the expression to evaluate and return if this is empty
- Definition Classes
- JsonOption
- Annotations
- @SuppressWarnings() @inline()
- See also
toLeft
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def withFilter(p: (A) => Boolean): WithFilter
Necessary to keep JsonOption from being implicitly converted to scala.collection.Iterable in
for
comprehensions.Necessary to keep JsonOption from being implicitly converted to scala.collection.Iterable in
for
comprehensions.- Definition Classes
- JsonOption
- Annotations
- @inline()
- val x: A
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)