Class ExtensionKt

  • All Implemented Interfaces:

    
    public final class ExtensionKt
    
                        
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final static T value
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final T getValue()
      final static <T extends JSONValue> Unit ifPresent(ResourceRef<JSONObject> $self, String name, Function2<ResourceRef<T>, T, Unit> block) Conditionally execute if JSONObject referenced by this ResourceRef contains a member with the specified key and the expected type.
      final static <T extends JSONPrimitive<R>, R extends Any> List<R> map(ResourceRef<JSONArray> $self) Map the values of the JSONArray referenced by this ResourceRef to an array of the primitive type for the JSONValue.
      final static <T extends JSONValue, R extends Any> List<R> map(ResourceRef<JSONArray> $self, Function2<ResourceRef<T>, Integer, R> transform) Map the values of the JSONArray referenced by this ResourceRef to an array of the target type, applying a transformation to each item.
      final static <T extends JSONValue, R extends Any> R map(ResourceRef<JSONObject> $self, String name, Function2<ResourceRef<T>, T, R> block) Map the JSONObject property referenced by this ResourceRef and the specified key, using the provided mapping function.
      final static <T extends JSONValue> Boolean any(ResourceRef<JSONArray> $self, Function2<ResourceRef<T>, Integer, Boolean> predicate) Return true if any of the values of the JSONArray referenced by this ResourceRef satisfy a given predicate.
      final static <T extends JSONValue> Boolean all(ResourceRef<JSONArray> $self, Function2<ResourceRef<T>, Integer, Boolean> predicate) Return true if all of the values of the JSONArray referenced by this ResourceRef satisfy a given predicate.
      final static String optionalString(ResourceRef<JSONObject> $self, String name) Get a String property from a JSONObject using this ResourceRef and the specified key, or null if the property is not present (throws an exception if the property is present but is the wrong type).
      final static Boolean optionalBoolean(ResourceRef<JSONObject> $self, String name) Get a Boolean property from a JSONObject using this ResourceRef and the specified key, or null if the property is not present (throws an exception if the property is present but is the wrong type).
      final static Integer optionalInt(ResourceRef<JSONObject> $self, String name) Get an Int property from a JSONObject using this ResourceRef and the specified key, or null if the property is not present (throws an exception if the property is present but is the wrong type).
      final static Long optionalLong(ResourceRef<JSONObject> $self, String name) Get a Long property from a JSONObject using this ResourceRef and the specified key, or null if the property is not present (throws an exception if the property is present but is not an Int or Long).
      final static BigDecimal optionalDecimal(ResourceRef<JSONObject> $self, String name) Get a BigDecimal property from a JSONObject using this ResourceRef and the specified key, or null if the property is not present (throws an exception if the property is present but is the wrong type).
      final static <T extends JSONValue> ResourceRef<T> optionalChild(ResourceRef<JSONObject> $self, String name) Get a child property ResourceRef from a JSONObject using this ResourceRef and the specified key, or null if the property is not present (throws an exception if the property is present but is the wrong type).
      final static <T extends JSONValue> Unit forEachKey(ResourceRef<JSONObject> $self, Function2<ResourceRef<T>, String, Unit> block) Iterate over the members of the JSONObject referenced by this ResourceRef.
      final static <T extends JSONValue> Unit forEach(ResourceRef<JSONArray> $self, Function2<ResourceRef<T>, Integer, Unit> block) Iterate over the members of the JSONArray referenced by this ResourceRef.
      final static <T extends JSONValue> ResourceRef<T> child(ResourceRef<JSONObject> $self, String name) Get the named child reference (strongly typed) from this JSONObject reference, using the implied child type.
      final static <T extends JSONValue> ResourceRef<T> child(ResourceRef<JSONArray> $self, Integer index) Get the named child reference (strongly typed) from this JSONArray reference, using the implied child type.
      final static ResourceRef<JSONValue> untypedChild(ResourceRef<JSONObject> $self, String name) Get the named child reference (untyped) from this JSONObject reference.
      final static ResourceRef<JSONValue> untypedChild(ResourceRef<JSONArray> $self, Integer index) Get the named child reference (untyped) from this JSONArray reference.
      final static <T extends JSONValue> Boolean hasChild(ResourceRef<JSONObject> $self, String name) Test whether this JSONObject reference has the named child with the implied type.
      final static <T extends JSONValue> Boolean hasChild(ResourceRef<JSONArray> $self, Integer index) Test whether this JSONArray reference has a child at the given index with the implied type.
      final static Unit checkName(ResourceRef<JSONObject> $self, String name) Check that this JSONObject reference has the named child, and throw an exception if not.
      final static Unit checkIndex(ResourceRef<JSONArray> $self, Integer index) Check that this JSONArray reference has a child at the given index, and throw an exception if not.
      final static ResourceRef<JSONObject> ref(Resource<JSONObject> $self) Load a Resource and create a reference.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • ifPresent

         final static <T extends JSONValue> Unit ifPresent(ResourceRef<JSONObject> $self, String name, Function2<ResourceRef<T>, T, Unit> block)

        Conditionally execute if JSONObject referenced by this ResourceRef contains a member with the specified key and the expected type.

        NOTE: this function will not throw an exception if the property is present but is of the wrong type, and it may be removed from future releases. To achieve the same effect with strong type checking, use:

            ref.optionalChild<JSONObject>("name")?.let { doSomething(it) }
      • map

         final static <T extends JSONPrimitive<R>, R extends Any> List<R> map(ResourceRef<JSONArray> $self)

        Map the values of the JSONArray referenced by this ResourceRef to an array of the primitive type for the JSONValue.

      • map

         final static <T extends JSONValue, R extends Any> List<R> map(ResourceRef<JSONArray> $self, Function2<ResourceRef<T>, Integer, R> transform)

        Map the values of the JSONArray referenced by this ResourceRef to an array of the target type, applying a transformation to each item.

      • map

        @Deprecated(message = "Confusing function name", replaceWith = @ReplaceWith(imports = {}, expression = "child(name).apply(block)")) final static <T extends JSONValue, R extends Any> R map(ResourceRef<JSONObject> $self, String name, Function2<ResourceRef<T>, T, R> block)

        Map the JSONObject property referenced by this ResourceRef and the specified key, using the provided mapping function.

      • optionalString

         final static String optionalString(ResourceRef<JSONObject> $self, String name)

        Get a String property from a JSONObject using this ResourceRef and the specified key, or null if the property is not present (throws an exception if the property is present but is the wrong type).

      • optionalBoolean

         final static Boolean optionalBoolean(ResourceRef<JSONObject> $self, String name)

        Get a Boolean property from a JSONObject using this ResourceRef and the specified key, or null if the property is not present (throws an exception if the property is present but is the wrong type).

      • optionalInt

         final static Integer optionalInt(ResourceRef<JSONObject> $self, String name)

        Get an Int property from a JSONObject using this ResourceRef and the specified key, or null if the property is not present (throws an exception if the property is present but is the wrong type).

      • optionalLong

         final static Long optionalLong(ResourceRef<JSONObject> $self, String name)

        Get a Long property from a JSONObject using this ResourceRef and the specified key, or null if the property is not present (throws an exception if the property is present but is not an Int or Long).

      • optionalChild

         final static <T extends JSONValue> ResourceRef<T> optionalChild(ResourceRef<JSONObject> $self, String name)

        Get a child property ResourceRef from a JSONObject using this ResourceRef and the specified key, or null if the property is not present (throws an exception if the property is present but is the wrong type).

      • child

         final static <T extends JSONValue> ResourceRef<T> child(ResourceRef<JSONObject> $self, String name)

        Get the named child reference (strongly typed) from this JSONObject reference, using the implied child type.

      • child

         final static <T extends JSONValue> ResourceRef<T> child(ResourceRef<JSONArray> $self, Integer index)

        Get the named child reference (strongly typed) from this JSONArray reference, using the implied child type.

      • hasChild

         final static <T extends JSONValue> Boolean hasChild(ResourceRef<JSONObject> $self, String name)

        Test whether this JSONObject reference has the named child with the implied type.

      • hasChild

         final static <T extends JSONValue> Boolean hasChild(ResourceRef<JSONArray> $self, Integer index)

        Test whether this JSONArray reference has a child at the given index with the implied type.

      • checkName

         final static Unit checkName(ResourceRef<JSONObject> $self, String name)

        Check that this JSONObject reference has the named child, and throw an exception if not.

      • checkIndex

         final static Unit checkIndex(ResourceRef<JSONArray> $self, Integer index)

        Check that this JSONArray reference has a child at the given index, and throw an exception if not.

      • ref

         final static ResourceRef<JSONObject> ref(Resource<JSONObject> $self)

        Load a Resource and create a reference.