From 10daee4220e645f53675ffeb06cdb6793348ba9b Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Mon, 4 Jul 2022 02:49:10 +0700 Subject: [PATCH] Add `Collection` methods for ArrayList/HashTable --- sources/Data/Collections/Collection.uc | 73 ++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/sources/Data/Collections/Collection.uc b/sources/Data/Collections/Collection.uc index 4344e12..4d63993 100644 --- a/sources/Data/Collections/Collection.uc +++ b/sources/Data/Collections/Collection.uc @@ -388,6 +388,43 @@ public final function DynamicArray GetDynamicArrayBy(BaseText jsonPointerAsText) return DynamicArray(GetItemBy(jsonPointerAsText)); } +/** + * Returns an `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. + * + * Referred value must be stored as `HashTable` + * (or one of it's sub-classes) for this method to work. + * + * @param jsonPointerAsText Description of a path to the `HashTable` value. + * @return `HashTable` value, stored at `jsonPointerAsText` or + * `none` if it is missing or has a different type. + */ +public final function HashTable GetHashTableBy( + BaseText jsonPointerAsText) +{ + return HashTable(GetItemBy(jsonPointerAsText)); +} + +/** + * Returns an `ArrayList` 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 `ArrayList` + * (or one of it's sub-classes) for this method to work. + * + * @param jsonPointerAsText Description of a path to the `ArrayList` value. + * @return `ArrayList` value, stored at `jsonPointerAsText` or + * `none` if it is missing or has a different type. + */ +public final function ArrayList GetArrayListBy(BaseText jsonPointerAsText) +{ + return ArrayList(GetItemBy(jsonPointerAsText)); +} + /** * Returns a `bool` value stored (in the caller `Collection` or * one of it's sub-collections) pointed by JSON pointer. @@ -589,6 +626,42 @@ public final function DynamicArray GetDynamicArrayByJSON( return DynamicArray(GetItemByJSON(jsonPointer)); } +/** + * Returns an `HashTable` 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 `HashTable` + * (or one of it's sub-classes) for this method to work. + * + * @param jsonPointer JSON path to the `HashTable` value. + * @return `HashTable` value, stored at `jsonPointerAsText` or + * `none` if it is missing or has a different type. + */ +public final function HashTable GetHashTableByJSON( + JSONPointer jsonPointer) +{ + return HashTable(GetItemByJSON(jsonPointer)); +} + +/** + * Returns an `ArrayList` 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 `ArrayList` + * (or one of it's sub-classes) for this method to work. + * + * @param jsonPointer JSON path to the `ArrayList` value. + * @return `ArrayList` value, stored at `jsonPointerAsText` or + * `none` if it is missing or has a different type. + */ +public final function ArrayList GetArrayListByJSON( + JSONPointer jsonPointer) +{ + return ArrayList(GetItemByJSON(jsonPointer)); +} + defaultproperties { } \ No newline at end of file