Gen
General Utilities
Gen is fully exported to scalqa root, thus all members and aliases of Gen can be called with or without "Gen." prefix.
For example:
val v: Gen.Number.Percent = ???
// is same as
val v: Gen.Percent = ???
// is same as
val v: Percent = ???
- Source
- __.scala
Member
General Instance Documentation
Doc is a buffer of (name,value) pairs, describing all instance properties
- Source
- __.scala
General Instance Documentation
Doc is a buffer of (name,value) pairs, describing all instance properties
- Source
- __.scala
General Request
General Request types establish some concept. They are always available without need to import.
Application classes and traits can have implicit conversions from General Request type to a local definition (for example).
Using general request singleton objects can make code more readable. There is no overhead because conversions are inlined.
Time.current.roundTo(1.Second)(using UP)
// vs.
Time.current.roundTo(1.Second)(using Gen.Rounding.Up)
Time.current.roundTo(1.Minute)(using DOWN)
// vs.
Time.current.roundTo(1.Minute)(using Gen.Rounding.Down)
val b: Int.Buffer = NEW
// vs.
val b: Int.Buffer = Int.Buffer()
val j: java.util.List[String] = NEW
// vs.
val j: java.util.List[String] = new java.util.ArrayList()
val l: Long = MAX
// vs.
val l: Long = Long.max
new Fx.Label("XYZ") {
alignment = RIGHT
// vs.
alignment = Fx.Pos.CenterRight
}
new Fx.Pane.Split{
orientation = VERTICAL
// vs.
orientation = Fx.Orientation.Vertical
}
new Fx.Menu {
items += SEPARATOR
// vs.
items += Fx.Menu.Item.separator
}
By far the most common request is VOID, which is a request for a void instance
var s: Stream[Int] = VOID // Assigning empty stream of Ints
var o: Opt[String] = VOID // Assigning empty optional value of String
var i: Long.Idx = VOID // Assigning empty indexed collection of Long
- Source
- __.scala
General Request
General Request types establish some concept. They are always available without need to import.
Application classes and traits can have implicit conversions from General Request type to a local definition (for example).
Using general request singleton objects can make code more readable. There is no overhead because conversions are inlined.
Time.current.roundTo(1.Second)(using UP)
// vs.
Time.current.roundTo(1.Second)(using Gen.Rounding.Up)
Time.current.roundTo(1.Minute)(using DOWN)
// vs.
Time.current.roundTo(1.Minute)(using Gen.Rounding.Down)
val b: Int.Buffer = NEW
// vs.
val b: Int.Buffer = Int.Buffer()
val j: java.util.List[String] = NEW
// vs.
val j: java.util.List[String] = new java.util.ArrayList()
val l: Long = MAX
// vs.
val l: Long = Long.max
new Fx.Label("XYZ") {
alignment = RIGHT
// vs.
alignment = Fx.Pos.CenterRight
}
new Fx.Pane.Split{
orientation = VERTICAL
// vs.
orientation = Fx.Orientation.Vertical
}
new Fx.Menu {
items += SEPARATOR
// vs.
items += Fx.Menu.Item.separator
}
By far the most common request is VOID, which is a request for a void instance
var s: Stream[Int] = VOID // Assigning empty stream of Ints
var o: Opt[String] = VOID // Assigning empty optional value of String
var i: Long.Idx = VOID // Assigning empty indexed collection of Long
- Source
- __.scala
General Void
Scalqa supports a concept of "void object" ("empty object"), which can be defined for any type. This is similar to Null Object Pattern.
Unlike "null", void object can have methods invoked, getting some behavior pertinent to 'voidness'
Examples:
- Void Stream is a singleton object of empty stream, which can be re-used for any type
- Void Opt, is a singleton optional value with no value, which can be re-used for any type
- Void String, is a string of zero length, which can be re-used for String type instead of null
- scala.Nil is a void instance, re-used for all parameterized scala.List types
Void objects have a standard way to declare their voidness by mixing this Void trait.
Alternatively, Able.Void trait can be mixed and "def isVoid"
test added explicitly.
For standard opaque types "def value_isVoid"
has to be overridden in companion object.
Types with void values have to define implicit conversions from \/.
class Foo
object Foo:
val void = new Foo with Void
implicit inline def implicitRequest(v:VOID): Foo = void
// Standard void assignment is:
val v: Foo=VOID
A standard way to test for voidness is universal .isVoid
method available for all types (including opaque).
- Source
- __.scala
General Void
Scalqa supports a concept of "void object" ("empty object"), which can be defined for any type. This is similar to Null Object Pattern.
Unlike "null", void object can have methods invoked, getting some behavior pertinent to 'voidness'
Examples:
- Void Stream is a singleton object of empty stream, which can be re-used for any type
- Void Opt, is a singleton optional value with no value, which can be re-used for any type
- Void String, is a string of zero length, which can be re-used for String type instead of null
- scala.Nil is a void instance, re-used for all parameterized scala.List types
Void objects have a standard way to declare their voidness by mixing this Void trait.
Alternatively, Able.Void trait can be mixed and "def isVoid"
test added explicitly.
For standard opaque types "def value_isVoid"
has to be overridden in companion object.
Types with void values have to define implicit conversions from \/.
class Foo
object Foo:
val void = new Foo with Void
implicit inline def implicitRequest(v:VOID): Foo = void
// Standard void assignment is:
val v: Foo=VOID
A standard way to test for voidness is universal .isVoid
method available for all types (including opaque).
- Source
- __.scala