Identifier class interface
An interface for an identifier of something, represented as String
, int
or BigInt
.
As this class is defined with the class modifier interface
, the class can
only be implemented, but not extended. This class also provides a default
implementation that allows constructing instaces of Identifier.
- Implemented types
- Annotations
-
- @immutable
Constructors
- Identifier.from(Object id)
-
An identifier from
id
that MUST be eitherString
,int
orBigInt
.const - Identifier.fromBigInt(BigInt id)
-
An identifier from
id
of the typeBigInt
.const - Identifier.fromInt(int id)
-
An identifier from
id
of the typeint
.const - Identifier.fromString(String id)
-
An identifier from
id
of the typeString
.const
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- isBigInt → bool
-
True if this value is stored as
BigInt
.no setteroverride - isInt → bool
-
True if this value is stored as
int
.no setteroverride - isInteger → bool
-
True if this value is stored as an integer (
int
orBigInt
) value.no setteroverride - isString → bool
-
True if this value is stored as a
String
.no setteroverride - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
asBigInt(
) → BigInt -
Returns this value as a
BigInt
value.override -
asInt(
) → int -
Returns this value as a
int
value.override -
asString(
) → String -
Returns this value as a
String
value.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
-
tryAsBigInt(
) → BigInt? -
This value as a
BigInt
value or null if cannot be converted toBigInt
.override -
tryAsInt(
) → int? -
This value as a
int
value or null if cannot be converted toint
.override -
tryAsString(
) → String? -
This value as a
String
value or null if cannot be converted toString
.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Static Methods
-
idOrNull(
Object? id) → Identifier? -
Prepares a nullable Identifier instance of the given
id
.