Reference Source
import CollectionVersion from 'devapt-core-common/js/base/collection_version.js'
public class | source

CollectionVersion

Extends:

LoggableErrorableCollectionBase → CollectionVersion

Versionned Instance objects collection

Example:

API:
		->set_version_getter(arg_getter):nothing - Set version getter.
		->get_version(arg_item):string - Get instance version.
		->compare_versions(arg_version1, arg_version2):integer - Compare two instance versions: v1 < v2 => -1, v1 = v2 => 0, v1 > v2 => 1.
		
		->get_latest_item(arg_name):Instance|undefined - Get latest version of item by its name.
		->get_latest_items():array - Get latest version of all items.
		->get_item_of_version(arg_name, arg_version):Instance|undefined - Get an item by its name and its version.
		->has_version(arg_item_name, arg_version):boolean -  Test if an item is inside the collection.
INHERITED API:
		->set_all(arg_items):nothing - Set all collection items. (INHERITED)
		->get_all(arg_types):array - Get all collection items or filter items with given type. (INHERITED)
		->get_all_names(arg_types):array - Get all items names with or without a filter on items types. (INHERITED)
		->get_all_ids():array - Get all items ids with or without a filter on items types. (INHERITED)

		->item(arg_name):Instance - Get an item by its name. (INHERITED)

		->get_count():number - Get all items count. (INHERITED)
		->get_first():object|undefined - Get first item. (INHERITED)
		->get_last():object|undefined - Get last item. (INHERITED)

		->add(arg_item):nothing - Add an item to the collection. (OVERWRITTEN)
		->add_first(arg_item):nothing - Add an item to the collection at the first position. (INHERITED)
		->remove(arg_item):nothing - Remove an item from the collection.
		->has(arg_item):boolean -  Test if an item is inside the collection.

		->find_by_name(arg_name):Instance|undefined - Find an item by its name into the collection.
		->find_by_id(arg_id):Instance|undefined - Find an item by its id into the collection.
		->find_by_attr(arg_attr_name, arg_attr_value):Instance|undefined - Find an item by one of its attributes into the collection.
		->find_by_filter(arg_filter_function):Instance|undefined - Find an item by a filter function.

		->filter_by_attr(arg_attr_name, arg_attr_value):array - Filter items by one of theirs attributes into the collection.
		->filter_by_filter(arg_filter_function):array - Filter items by a filter function.

		->get_accepted_types():array - Get all collection accepted types.
		->set_accepted_types(arg_types):nothing - Set all collection accepted types.
		->add_accepted_type(arg_type):nothing - Add one collection accepted type.
		->has_accepted_type(arg_type):boolean - Test if collection has given accepted type.

		->forEach(arg_cb):nothing - forEach wrapper on ordered items.

Constructor Summary

Public Constructor
public

constructor(args: ...Instance): nothing

Create a collection of versionned Instance objects.

Member Summary

Public Members
public

Get version helper.

public

Class type flag.

Private Members
private

Items versions names map.

private

Items last version names map.

Method Summary

Public Methods
public

compare_versions(arg_version1: string, arg_version2: string): integer

Compare two instance versions: v1 < v2 => -1, v1 = v2 => 0, v1 > v2 => 1.

public

get_item_of_version(arg_name: string, arg_version: string): Instance | undefined

Get an item by its name and its version.

public

Get latest version of item by its name.

public

get_latest_items(): array

Get latest version of all items.

public

Get instance version.

public

has_version(arg_item_name: string, arg_version: string): boolean

Test if an item is inside the collection.

public

set_version_getter(arg_getter: Function): nothing

Set version getter.

Private Methods
private

_add(arg_item: Instance): nothing

Add an item to the collection without type checks (unsafe).

private

_add_first(arg_item: Instance): nothing

Add an item to the collection without type checks at first position (unsafe).

private

_has(arg_item: Instance): boolean

Test if an item is inside the collection without type checks (unsafe).

private

_remove(arg_item: Instance): nothing

Remove an item from the collection without type checks (unsafe).

Inherited Summary

From class Loggable
public

Log context.

public

Class type flag.

public

Trace is enabled for this flag.

private

Logger manager instance (default undefined)

public

debug(args: string | array): nothing

Trace DEBUG formatted message.

public

disable_trace(): nothing

Disable traces.

public

enable_trace(): nothing

Enable traces.

public

enter_group(arg_group: string): nothing

Trace INFO message on "enter trace group".

public

error(args: string | array): nothing

Trace ERROR formatted message.

public

Define get class name method for non Instance classes.

public

Get instance context.

public

Get logger manager.

public

Define get instance name method for non Instance classes.

public

Get trace flag.

public

info(args: string | array): nothing

Trace INFO formatted message.

public

leave_group(arg_group: string): nothing

Trace INFO message on "leave trace group".

public

separate_level_1(): nothing

Trace INFO trace level 1 separator.

public

separate_level_2(): nothing

Trace INFO trace level 2 separator.

public

separate_level_3(): nothing

Trace INFO trace level 3 separator.

public

set_trace(arg_value: boolean): nothing

Set trace flag.

public

should_trace(arg_traces_cfg: object): boolean

Calculate should trace flag.

public

should_trace_class(arg_traces_cfg: object): boolean

Calculate should trace flag for classes.

public

should_trace_collection_item(arg_traces_cfg: object, arg_collection_name: string, arg_this_item_accessor: string): boolean

Calculate should trace flag for given collection of names or patterns.

public

should_trace_module(arg_traces_cfg: object): boolean

Calculate should trace flag for modules.

public

should_trace_name(arg_traces_cfg: object): boolean

Calculate should trace flag for instances names.

public

Toggle trace flag.

public

Update trace enabled flag.

public

warn(args: string | array): nothing

Trace WARN formatted message.

From class Errorable
private

Error text (default null).

private

Has error flag (default false).

public

error(arg_msg: string): nothing

Set an error.

public

Default helper for "not implemented" error.

public

Get error message.

public

Test is an error is set.

From class CollectionBase
public

Class type flag.

private

Accepted types array.

private

_items_array: array

Items array.

private

Items ids map.

private

Items names map.

public

add(arg_item: Instance): nothing

Add an item to the collection.

public

add_accepted_type(arg_type: string): nothing

Add one collection accepted type.

public

add_first(arg_item: Instance): nothing

Add an item to the collection at the first position.

public

filter_by_attr(arg_attr_name: string, arg_attr_value: any): array

Filter items by one of theirs attributes into the collection.

public

filter_by_filter(arg_filter_function: string): array

Filter items by a filter function.

public

find_by_attr(arg_attr_name: string, arg_attr_value: any): Instance | undefined

Find an item by one of its attributes into the collection.

public

find_by_filter(arg_filter_function: string): Instance | undefined

Find an item by a filter function.

public

Find an item by its id into the collection.

public

Find an item by its name into the collection.

public

forEach(arg_cb: function): nothing

forEach wrapper on ordered items.

public

get(arg_name: string): Instance | undefined

Get an item by its name.

public

Get all collection accepted types.

public

get_all(arg_types: array | string | nothing): array

Get all collection items or filter items with given type.

public

get_all_ids(): array

Get all items ids with or without a filter on items types.

public

get_all_names(arg_types: array | string | nothing): array

Get all items names with or without a filter on items types.

public

Get all items count.

public

Get first item.

public

Get last item.

public

has(arg_item: Instance): boolean

Test if an item is inside the collection.

public

Test if collection has given accepted type.

public

item(arg_name: string): Instance | undefined

Get an item by its name.

public

remove(arg_item: Instance): nothing

Remove an item from the collection.

public

set_accepted_types(arg_types: array): nothing

Set all collection accepted types.

public

set_all(arg_items: Instance | array): nothing

Set all collection items.

public

toString(): *

Format string dump.

private

_add(arg_item: Instance): nothing

Add an item to the collection without type checks (unsafe).

private

_add_first(arg_item: Instance): nothing

Add an item to the collection without type checks at first position (unsafe).

private

_get_all(): array

Get all collection items.

private

_has(arg_item: Instance): boolean

Test if an item is inside the collection without type checks (unsafe).

private

_remove(arg_item: Instance): nothing

Remove an item from the collection without type checks (unsafe).

private

_set_all(arg_items: array): nothing

Set all collection items.

Public Constructors

public constructor(args: ...Instance): nothing source

Create a collection of versionned Instance objects.

Override:

CollectionBase#constructor

Params:

NameTypeAttributeDescription
args ...Instance

variadic list of Instance.

Return:

nothing

Public Members

public $version_getter: function source

Get version helper.

public is_collection_version: boolean source

Class type flag.

Private Members

private _items_by_name_by_version: object source

Items versions names map.

private _items_by_name_latest_version: object source

Items last version names map.

Public Methods

public compare_versions(arg_version1: string, arg_version2: string): integer source

Compare two instance versions: v1 < v2 => -1, v1 = v2 => 0, v1 > v2 => 1.

Params:

NameTypeAttributeDescription
arg_version1 string

requested instance 1 version.

arg_version2 string

requested instance 2 version.

Return:

integer

public get_item_of_version(arg_name: string, arg_version: string): Instance | undefined source

Get an item by its name and its version.

Params:

NameTypeAttributeDescription
arg_name string

requested instance name.

arg_version string

requested instance version.

Return:

Instance | undefined

public get_latest_item(arg_name: string): Instance | undefined source

Get latest version of item by its name.

Params:

NameTypeAttributeDescription
arg_name string

instance name.

Return:

Instance | undefined

public get_latest_items(): array source

Get latest version of all items.

Return:

array

public get_version(arg_item: Instance): string source

Get instance version.

Params:

NameTypeAttributeDescription
arg_item Instance

Instance item.

Return:

string

public has_version(arg_item_name: string, arg_version: string): boolean source

Test if an item is inside the collection.

Params:

NameTypeAttributeDescription
arg_item_name string

Instance item name.

arg_version string

requested instance version.

Return:

boolean

public set_version_getter(arg_getter: Function): nothing source

Set version getter.

Params:

NameTypeAttributeDescription
arg_getter Function

instance version getter.

Return:

nothing

Private Methods

private _add(arg_item: Instance): nothing source

Add an item to the collection without type checks (unsafe).

Override:

CollectionBase#_add

Params:

NameTypeAttributeDescription
arg_item Instance

Instance item.

Return:

nothing

private _add_first(arg_item: Instance): nothing source

Add an item to the collection without type checks at first position (unsafe).

Override:

CollectionBase#_add_first

Params:

NameTypeAttributeDescription
arg_item Instance

Instance item.

Return:

nothing

private _has(arg_item: Instance): boolean source

Test if an item is inside the collection without type checks (unsafe).

Override:

CollectionBase#_has

Params:

NameTypeAttributeDescription
arg_item Instance

Instance item.

Return:

boolean

private _remove(arg_item: Instance): nothing source

Remove an item from the collection without type checks (unsafe).

Override:

CollectionBase#_remove

Params:

NameTypeAttributeDescription
arg_item Instance

Instance item.

Return:

nothing