import CollectionVersion from 'devapt-core-common/js/base/collection_version.js'
CollectionVersion
Extends:
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_item(arg_name: string): Instance | undefined Get latest version of item by its name. |
|
public |
get_latest_items(): array Get latest version of all items. |
|
public |
get_version(arg_item: Instance): string 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 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 |
Test if an item is inside the collection without type checks (unsafe). |
|
private |
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 |
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 |
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 |
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 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(): nothing Update trace enabled flag. |
|
public |
Trace WARN formatted message. |
From class Errorable | ||
private |
Error text (default null). |
|
private |
Has error flag (default false). |
|
public |
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 Accepted types array. |
|
private |
_items_array: array Items array. |
|
private |
Items ids map. |
|
private |
Items names map. |
|
public |
Add an item to the collection. |
|
public |
add_accepted_type(arg_type: string): nothing Add one collection accepted type. |
|
public |
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_by_id(arg_id: string): Instance | undefined Find an item by its id into the collection. |
|
public |
find_by_name(arg_name: string): Instance | undefined Find an item by its name into the collection. |
|
public |
forEach wrapper on ordered items. |
|
public |
Get an item by its name. |
|
public |
get_accepted_types(): array Get all collection accepted types. |
|
public |
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 |
Test if an item is inside the collection. |
|
public |
has_accepted_type(arg_type: string): boolean Test if collection has given accepted type. |
|
public |
Get an item by its name. |
|
public |
Remove an item from the collection. |
|
public |
set_accepted_types(arg_types: array): nothing Set all collection accepted types. |
|
public |
Set all collection items. |
|
public |
toString(): * Format string dump. |
|
private |
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 |
Test if an item is inside the collection without type checks (unsafe). |
|
private |
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#constructorParams:
Name | Type | Attribute | Description |
args | ...Instance | variadic list of Instance. |
Return:
nothing |
Public Members
Private Members
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.
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.
public get_latest_item(arg_name: string): Instance | undefined source
Get latest version of item by its name.
Params:
Name | Type | Attribute | Description |
arg_name | string | instance name. |
public get_version(arg_item: Instance): string source
Get instance version.
Params:
Name | Type | Attribute | Description |
arg_item | Instance | Instance item. |
public has_version(arg_item_name: string, arg_version: string): boolean source
Test if an item is inside the collection.
public set_version_getter(arg_getter: Function): nothing source
Set version getter.
Params:
Name | Type | Attribute | Description |
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#_addParams:
Name | Type | Attribute | Description |
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_firstParams:
Name | Type | Attribute | Description |
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#_hasParams:
Name | Type | Attribute | Description |
arg_item | Instance | Instance item. |
private _remove(arg_item: Instance): nothing source
Remove an item from the collection without type checks (unsafe).
Override:
CollectionBase#_removeParams:
Name | Type | Attribute | Description |
arg_item | Instance | Instance item. |
Return:
nothing |