Enum
pentaho.type.mixins. Enum
A mixin type that limits the domain, of the simple type it is applied to, to a discrete set of instances.
Enum types become final (cannot be further subtyped).
The alias of this type is enum
.
The discrete set of valid instances must be specified at type initialization.
The order of instances is relevant and is accounted for in compare
.
AMD Module
require(["pentaho/type/mixins/Enum"], function(Enum) { /* code goes here */ });
See also: pentaho.type.mixins.spec.IEnumType
Extends
Constructor
Name | Description |
---|---|
new Enum() Abstract |
Members
Name | Description |
---|---|
$contentKey : string | Gets the content key of the simple value. |
$isValid : boolean | Determines if this value is a valid. |
$key : string | Gets the key of the simple value. |
$type : pentaho.type.ValueType | Gets the type of this instance. |
formatted : nonEmptyString | Gets the formatted value of the property. |
value : * | Gets the underlying JavaScript value represented by the simple value. |
Methods
Name | Description |
---|---|
_compare(other) : number Protected | Compares this element to a distinct, non-equal element of the same type according to its relative order. |
_configure(config) Protected | Configures this value with a given distinct and non- |
_configureOrCreate(config) : pentaho.type.Element Protected | Configures this value with a given distinct and non- |
_toJSONValue(keyArgs) : JsonValue Protected | Converts the |
assertValid() | Ensures that the value is valid, and throws the first validation error if it is not. |
clone() : pentaho.type.Simple | Creates a clone of the simple value. |
compare(other) : number | Compares this element to another according to its relative order. |
configure(config) | Configures this value with a given configuration. |
configureOrCreate(config) : pentaho.type.Element | Configures this value with a given configuration, if it is possible. Otherwise creates and returns a new value based on this one, but with the configuration applied. |
equals(other) : boolean | Determines if a given value represents the same entity. |
toJSON() : JsonValue | Creates a top-level JSON specification that describes this instance. |
toSpec(keyArgs) : pentaho.type.spec.Instance | Creates a specification that describes this value. |
toSpecInContext(keyArgs) : * | Creates a specification that describes this instance. |
toString() : string | Gets a string that represents the current simple value. |
validate() : Array.<pentaho.type.ValidationError> | Determines if this value is valid. |
valueOf() : * | Gets the underlying primitive value of the simple value. |
Constructor Details
new Enum() Abstract |
---|
Source: javascript/web/pentaho/type/mixins/Enum.js, line 38 See also: pentaho.type.mixins.spec.IEnumType Example Defining an enumeration type ```js define([ "pentaho/module!_", "pentaho/type/String" ], function(module, PenString) { return PenString.extend({ $type: { id: module.id, mixins: ["enum"], domain: [ {v: "bad", f: "Bad"}, {v: "neutral", f: "Neutral"}, {v: "good", f: "Good"} ] } }) .configure(); }); ``` |
Members Details
$contentKey: string |
---|
Gets the content key of the simple value. Source: javascript/web/pentaho/type/Simple.js, line 158 Inherited From: pentaho.type.Simple#$contentKey |
$isValid: boolean |
---|
Determines if this value is a valid. This attribute calls Source: javascript/web/pentaho/type/Value.js, line 168 Inherited From: pentaho.type.Value#$isValid |
$key: string |
---|
Gets the key of the simple value. The default simple value implementation, returns the result of calling Source: javascript/web/pentaho/type/Simple.js, line 148 Inherited From: pentaho.type.Simple#$key See also: pentaho.type.SimpleType#isEntity |
$type: pentaho.type.ValueType |
---|
Gets the type of this instance. Source: javascript/web/pentaho/type/Value.js, line 334 Overrides: pentaho.type.Simple#$type |
formatted: nonEmptyString |
---|
Gets the formatted value of the property. Source: javascript/web/pentaho/type/Simple.js, line 98 Inherited From: pentaho.type.Simple#formatted |
value: * |
---|
Gets the underlying JavaScript value represented by the simple value. Source: javascript/web/pentaho/type/Simple.js, line 89 Inherited From: pentaho.type.Simple#value |
Methods Details
_compare(other) : number Protected | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Compares this element to a distinct, non-equal element of the same type according to its relative order. This method compares the primitive value of this value with that of Source: javascript/web/pentaho/type/Simple.js, line 214 Inherited From: pentaho.type.Simple#_compare
See also: pentaho.type.SimpleType#comparePrimitiveValues |
_configure(config) Protected | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Configures this value with a given distinct and non- This method can only be called when there is an ambient transaction. The default implementation throws an error if this value's type is Source: javascript/web/pentaho/type/Value.js, line 264 Inherited From: pentaho.type.Value#_configure
See also: pentaho.type.Value#configure , pentaho.type.Complex#_configure , pentaho.type.List#_configure |
_configureOrCreate(config) : pentaho.type.Element Protected | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Configures this value with a given distinct and non- This method can only be called when there is an ambient transaction. Source: javascript/web/pentaho/type/Element.js, line 175 Inherited From: pentaho.type.Element#_configureOrCreate
See also: pentaho.type.Element#configureOrCreate , pentaho.type.Value#configure |
_toJSONValue(keyArgs) : JsonValue Protected | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Converts the The default implementation returns Source: javascript/web/pentaho/type/Simple.js, line 287 Inherited From: pentaho.type.Simple#_toJSONValue
|
assertValid() | ||||
---|---|---|---|---|
Ensures that the value is valid, and throws the first validation error if it is not. This method calls the Source: javascript/web/pentaho/type/Value.js, line 202 Inherited From: pentaho.type.Value#assertValid
|
clone() : pentaho.type.Simple | ||||
---|---|---|---|---|
Creates a clone of the simple value. Source: javascript/web/pentaho/type/Simple.js, line 113 Inherited From: pentaho.type.Simple#clone
|
compare(other) : number | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Compares this element to another according to its relative order. Execution proceeds as follows:
Source: javascript/web/pentaho/type/Element.js, line 76 Inherited From: pentaho.type.Element#compare
See also: pentaho.type.Element#_compare , pentaho.type.Value#equals |
configure(config) | ||
---|---|---|
Configures this value with a given configuration. This method ensures a transaction exists and then delegates to For more information on the semantics of configuration, see Source: javascript/web/pentaho/type/Value.js, line 232 Inherited From: pentaho.type.Value#configure |
Name | Default Value | Summary |
---|---|---|
config : * | The value configuration. |
Name | Description |
---|---|
TypeError | When the value would be changed and its type is |
See also: pentaho.type.Element#configureOrCreate , pentaho.type.Complex#_configure , pentaho.type.List#_configure
configureOrCreate(config) : pentaho.type.Element | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Configures this value with a given configuration, if it is possible. Otherwise creates and returns a new value based on this one, but with the configuration applied. If the given configuration is This method considers configuration to not be possible in the following situations:
If configuration is considered possible, the actual configuration is delegated to the Source: javascript/web/pentaho/type/Element.js, line 141 Inherited From: pentaho.type.Element#configureOrCreate
|
equals(other) : boolean | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Determines if a given value represents the same entity. This method checks if the given value is identical to this one. Otherwise, if not Source: javascript/web/pentaho/type/Value.js, line 116 Inherited From: pentaho.type.Value#equals
See also: pentaho.type.Value#_equals |
toJSON() : JsonValue | ||||
---|---|---|---|---|
Creates a top-level JSON specification that describes this instance. Attributes which do not have a JSON-compatible specification are omitted. Specifically, for inline types, attributes with a function value are not supported. This method simply calls Source: javascript/web/pentaho/type/Instance.js, line 198 Inherited From: pentaho.type.Instance#toJSON
See also: pentaho.type.Instance#toSpec |
toSpec(keyArgs) : pentaho.type.spec.Instance | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Creates a specification that describes this value. If an Source: javascript/web/pentaho/type/Value.js, line 272 Inherited From: pentaho.type.Value#toSpec |
Name | Default Value | Summary | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
keyArgs : object Optional | The keyword arguments object. Passed to every value and type serialized within this scope. Please see the documentation of value subclasses for information on additional, supported keyword arguments.
|
Name | Description |
---|---|
pentaho.type.spec.Instance | null | A specification of this value. |
toSpecInContext(keyArgs) : * | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Creates a specification that describes this instance. Source: javascript/web/pentaho/type/Instance.js, line 178 Inherited From: pentaho.type.Instance#toSpecInContext
See also: pentaho.type.Instance#toSpec |
toString() : string | ||||
---|---|---|---|---|
Gets a string that represents the current simple value. Source: javascript/web/pentaho/type/Simple.js, line 133 Inherited From: pentaho.type.Simple#toString
|
validate() : Array.<pentaho.type.ValidationError> | ||||
---|---|---|---|---|
Determines if this value is valid. The default implementation does nothing and considers the instance valid. Override to implement a type's specific validation logic. You can use the error utilities in Source: javascript/web/pentaho/type/Value.js, line 187 Overrides: pentaho.type.Simple#validate
See also: pentaho.type.Value#$isValid |
valueOf() : * | ||||
---|---|---|---|---|
Gets the underlying primitive value of the simple value. Source: javascript/web/pentaho/type/Simple.js, line 124 Inherited From: pentaho.type.Simple#valueOf
|