Class ApiTypeHelper

java.lang.Object
co.elastic.clients.util.ApiTypeHelper

public class ApiTypeHelper extends Object
Utility functions for API model types
  • Method Details

    • requiredPropertiesCheckDisabled

      public static boolean requiredPropertiesCheckDisabled()
    • DANGEROUS_disableRequiredPropertiesCheck

      public static ApiTypeHelper.DisabledChecksHandle DANGEROUS_disableRequiredPropertiesCheck(boolean disable)
      DANGEROUS! Allows disabling the verification of required properties on the current thread when calling ObjectBuilder.build(). This can lead properties expected to be always present to be null, or have the default value for primitive types.

      This can be used as a workaround for properties that are erroneously marked as required. If you have to use it, please file a bug at https://github.com/elastic/elasticsearch-java/issues to report the offending property.

      The result of this method is an AutoCloseable handle that can be used in try-with-resource blocks to precisely limit the scope where checks are disabled.

    • requireNonNull

      public static <T> T requireNonNull(T value, Object obj, String name)
    • undefinedList

      public static <T> List<T> undefinedList()
      Returns an empty list that is undefined from a JSON perspective. It will not be serialized when used as the value of an array property in API objects.
    • isDefined

      public static <T> boolean isDefined(List<T> list)
      Is list defined according to JSON/JavaScript semantics?
      Returns:
      true if list is not null and not undefinedList()
    • unmodifiable

      public static <T> List<T> unmodifiable(@Nullable List<T> list)
      Returns an unmodifiable view of a list. If list is null, an undefinedList() is returned.
    • unmodifiableRequired

      public static <T> List<T> unmodifiableRequired(List<T> list, Object obj, String name)
      Returns an unmodifiable view of a required list.
    • undefinedMap

      public static <K, V> Map<K,V> undefinedMap()
      Returns an empty list that is undefined from a JSON perspective. It will not be serialized when used as the value of an array property in API objects.
    • isDefined

      public static <K, V> boolean isDefined(Map<K,V> map)
      Is map defined according to JSON/JavaScript semantics?
      Returns:
      true if map is not null and not undefinedMap()
    • unmodifiable

      public static <K, V> Map<K,V> unmodifiable(Map<K,V> map)
      Returns an unmodifiable view of a map. If map is null, an undefinedMap() is returned.
    • unmodifiableRequired

      public static <K, V> Map<K,V> unmodifiableRequired(Map<K,V> map, Object obj, String name)
      Returns an unmodifiable view of a required map.