Browse Source

Add specialized getters for returning `Collection`s to themselves

core_refactor
Anton Tarasenko 2 years ago
parent
commit
e46debe99f
  1. 59
      sources/Data/Collections/Collection.uc

59
sources/Data/Collections/Collection.uc

@ -522,7 +522,35 @@ public final function Text GetTextBy(BaseText jsonPointerAsText)
} }
/** /**
* Returns an `HashTable` value (stored in the caller `Collection` or * Returns a generic `Collection` value (stored in the caller `Collection` or
* one of it's sub-collections) pointed by
* [JSON pointer](https://tools.ietf.org/html/rfc6901).
* See `GetItemBy()` for more information.
*
* Referred value must be stored as `Collection`
* (or one of it's sub-classes) for this method to work.
*
* @param jsonPointerAsText Description of a path to the `Collection` value.
* @return `Collection` value, stored at `jsonPointerAsText` or
* `none` if it is missing or has a different type.
*/
public final function Collection GetCollectionBy(
BaseText jsonPointerAsText)
{
local Collection asCollection;
local AcediaObject result;
result = GetItemBy(jsonPointerAsText);
asCollection = Collection(result);
if (asCollection != none) {
return asCollection;
}
_.memory.Free(result);
return none;
}
/**
* Returns a `HashTable` value (stored in the caller `Collection` or
* one of it's sub-collections) pointed by * one of it's sub-collections) pointed by
* [JSON pointer](https://tools.ietf.org/html/rfc6901). * [JSON pointer](https://tools.ietf.org/html/rfc6901).
* See `GetItemBy()` for more information. * See `GetItemBy()` for more information.
@ -904,7 +932,34 @@ public final function Text GetTextByJSON(JSONPointer jsonPointer)
} }
/** /**
* Returns an `HashTable` value (stored in the caller `Collection` or * Returns a generic `Collection` value (stored in the caller `Collection` or
* one of it's sub-collections) pointed by JSON pointer.
* See `GetItemByJSON()` for more information.
*
* Referred value must be stored as `Collection`
* (or one of it's sub-classes) for this method to work.
*
* @param jsonPointer JSON path to the `Collection` value.
* @return `Collection` value, stored at `jsonPointerAsText` or
* `none` if it is missing or has a different type.
*/
public final function Collection GetCollectionByJSON(
JSONPointer jsonPointer)
{
local AcediaObject result;
local Collection asCollection;
result = GetItemByJSON(jsonPointer);
asCollection = Collection(result);
if (asCollection != none) {
return asCollection;
}
_.memory.Free(result);
return none;
}
/**
* Returns a `HashTable` value (stored in the caller `Collection` or
* one of it's sub-collections) pointed by JSON pointer. * one of it's sub-collections) pointed by JSON pointer.
* See `GetItemByJSON()` for more information. * See `GetItemByJSON()` for more information.
* *

Loading…
Cancel
Save