Show:

Enum Class

Defined in: a05_enum.js:9
Module: core

Base class for all Breeze enumerations, such as EntityState, DataType, FetchStrategy, MergeStrategy etc. A Breeze Enum is a namespaced set of constant values. Each Enum consists of a group of related constants, called 'symbols'. Unlike enums in some other environments, each 'symbol' can have both methods and properties.

Methods

<ctor> Enum

(
  • name
  • [methodObj]
)

Defined in a05_enum.js:51

Enum constructor - may be used to create new Enums.

Parameters:

  • name String
  • [methodObj] Object optional

Example:

var prototype = {
    nextDay: function () {
        var nextIndex = (this.dayIndex+1) % 7;
        return DayOfWeek.getSymbols()[nextIndex];
    }
};

var DayOfWeek = new Enum("DayOfWeek", prototype);

addSymbol

(
  • [propertiesObj]
)
EnumSymbol

Defined in a05_enum.js:107

Adds a new symbol to an Enum.

Parameters:

  • [propertiesObj] Object optional

    A collection of properties that should be added to the new symbol. In other words, the 'propertiesObj' is any state that should be held by the symbol.

Returns:

EnumSymbol:

The new symbol

Example:

var DayOfWeek = new Enum("DayOfWeek", prototype);
DayOfWeek.Monday    = DayOfWeek.addSymbol( { dayIndex: 0 });

contains

(
  • Object
)
Boolean

Defined in a05_enum.js:203

Returns whether an Enum contains a specified symbol.

Parameters:

  • Object Object

    or symbol to test.

Returns:

Boolean:

Whether this Enum contains the specified symbol.

Example:

var symbol = DayOfWeek.Friday;
if (DayOfWeek.contains(symbol)) {
    // do something
}

fromName

(
  • name
)
EnumSymbol

Defined in a05_enum.js:94

Returns an Enum symbol given its name.

Parameters:

  • name String

    Name for which an enum symbol should be returned.

Returns:

EnumSymbol:

The symbol that matches the name or 'undefined' if not found.

Example:

var dayOfWeek = DayOfWeek.from("Thursday");
// nowdayOfWeek === DayOfWeek.Thursday

getNames

() Array of String

Defined in a05_enum.js:184

Returns the names of all of the symbols contained within this Enum.

Returns:

Array of String:

All of the names of the symbols contained within this Enum.

Example:

var symbols = DayOfWeek.getNames();

getSymbols

() Array of EnumSymbol

Defined in a05_enum.js:171

Returns all of the symbols contained within this Enum.

Returns:

Array of EnumSymbol:

All of the symbols contained within this Enum.

Example:

var symbols = DayOfWeek.getSymbols();

isSymbol

() Boolean static

Defined in a05_enum.js:80

Checks if an object is an Enum 'symbol'.

Returns:

Boolean:

Example:

if (Enum.isSymbol(DayOfWeek.Wednesday)) {
  // do something ...
};

resolveSymbols

()

Defined in a05_enum.js:131

Seals this enum so that no more symbols may be added to it. This should only be called after all symbols have already been added to the Enum.

Example:

DayOfWeek.resolveSymbols();