diff --git a/sources/Data/Collections/Collection.uc b/sources/Data/Collections/Collection.uc index 322283c..4c48beb 100644 --- a/sources/Data/Collections/Collection.uc +++ b/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 * [JSON pointer](https://tools.ietf.org/html/rfc6901). * 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. * See `GetItemByJSON()` for more information. *