PrimitiveValue

zio.blocks.schema.PrimitiveValue
See thePrimitiveValue companion object
sealed trait PrimitiveValue

A PrimitiveValue is a scalar value inside a DynamicValue, which DynamicValue.Primitive wraps. There is one case per PrimitiveType, and each case keeps the exact Scala or Java type of its value: Int(2021) and Long(2021L) are different values.

Primitive values are ordered: two values of the same case by their value, and values of different cases by the order of the cases, from Unit to UUID (see typeIndex). PrimitiveValue.ordering and DynamicValue#compare use this order. Int values are compared by subtraction, which overflows, so two Int values that are more than Int.MaxValue apart compare the wrong way round.

val title = PrimitiveValue.String("Zionomicon")
val year  = PrimitiveValue.Int(2021)

val kind   = year.primitiveType                       // Int(None)
val before = year < PrimitiveValue.Int(2024)          // true
val sorted = List[PrimitiveValue](title, year).sorted // List(Int(2021), String(Zionomicon))
val value  = DynamicValue.Primitive(title)            // "Zionomicon"

Attributes

See also
Companion
object
Source
PrimitiveValue.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class BigDecimal
class BigInt
class Boolean
class Byte
class Char
class Currency
class DayOfWeek
class Double
class Duration
class Float
class Instant
class Int
class LocalDate
class LocalTime
class Long
class Month
class MonthDay
class OffsetTime
class Period
class Short
class String
class UUID
object Unit
class Year
class YearMonth
class ZoneId
class ZoneOffset
Show all

Members list

Type members

Types

type Type

The Scala or Java type of the value.

The Scala or Java type of the value.

Attributes

Source
PrimitiveValue.scala

Value members

Abstract methods

def compare(that: PrimitiveValue): Int

Returns a negative number, zero or a positive number when this value is less than, equal to or greater than that. Values of the same case are compared by their value, except as noted on Int and Period; values of different cases by typeIndex.

Returns a negative number, zero or a positive number when this value is less than, equal to or greater than that. Values of the same case are compared by their value, except as noted on Int and Period; values of different cases by typeIndex.

Attributes

Source
PrimitiveValue.scala

Returns the PrimitiveType of the value, without validation.

Returns the PrimitiveType of the value, without validation.

Attributes

Source
PrimitiveValue.scala
def typeIndex: Int

Returns the position of this case in the list of cases, from 0 for Unit to 29 for UUID. Values of different cases are ordered by it.

Returns the position of this case in the list of cases, from 0 for Unit to 29 for UUID. Values of different cases are ordered by it.

Attributes

Source
PrimitiveValue.scala

Concrete methods

final def <(that: PrimitiveValue): Boolean

Returns true when this value is less than that by compare.

Returns true when this value is less than that by compare.

Attributes

Source
PrimitiveValue.scala
final def <=(that: PrimitiveValue): Boolean

Returns true when this value is less than or equal to that by compare.

Returns true when this value is less than or equal to that by compare.

Attributes

Source
PrimitiveValue.scala
final def >(that: PrimitiveValue): Boolean

Returns true when this value is greater than that by compare.

Returns true when this value is greater than that by compare.

Attributes

Source
PrimitiveValue.scala
final def >=(that: PrimitiveValue): Boolean

Returns true when this value is greater than or equal to that by compare.

Returns true when this value is greater than or equal to that by compare.

Attributes

Source
PrimitiveValue.scala