Package co.elastic.clients.util
Class ApiTypeHelper
java.lang.Object
co.elastic.clients.util.ApiTypeHelper
public class ApiTypeHelper
extends java.lang.Object
Utility functions for API model types
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ApiTypeHelper.DisabledChecksHandle
-
Method Summary
Modifier and Type Method Description static ApiTypeHelper.DisabledChecksHandle
DANGEROUS_disableRequiredPropertiesCheck(boolean disable)
DANGEROUS! Allows disabling the verification of required properties on the current thread when callingObjectBuilder.build()
.static <T> boolean
isDefined(java.util.List<T> list)
Islist
defined according to JSON/JavaScript semantics?static <K, V> boolean
isDefined(java.util.Map<K,V> map)
Ismap
defined according to JSON/JavaScript semantics?static boolean
requiredPropertiesCheckDisabled()
static <T> T
requireNonNull(T value, java.lang.Object obj, java.lang.String name)
static <T> java.util.List<T>
undefinedList()
Returns an empty list that is undefined from a JSON perspective.static <K, V> java.util.Map<K,V>
undefinedMap()
Returns an empty list that is undefined from a JSON perspective.static <T> java.util.List<T>
unmodifiable(java.util.List<T> list)
Returns an unmodifiable view of a list.static <K, V> java.util.Map<K,V>
unmodifiable(java.util.Map<K,V> map)
Returns an unmodifiable view of a map.static <T> java.util.List<T>
unmodifiableRequired(java.util.List<T> list, java.lang.Object obj, java.lang.String name)
Returns an unmodifiable view of a required list.static <K, V> java.util.Map<K,V>
unmodifiableRequired(java.util.Map<K,V> map, java.lang.Object obj, java.lang.String name)
Returns an unmodifiable view of a required map.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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 callingObjectBuilder.build()
. This can lead properties expected to be always present to benull
, 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, java.lang.Object obj, java.lang.String name) -
undefinedList
public static <T> java.util.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(java.util.List<T> list)Islist
defined according to JSON/JavaScript semantics?- Returns:
- true if
list
is notnull
and notundefinedList()
-
unmodifiable
public static <T> java.util.List<T> unmodifiable(@Nullable java.util.List<T> list) -
unmodifiableRequired
public static <T> java.util.List<T> unmodifiableRequired(java.util.List<T> list, java.lang.Object obj, java.lang.String name)Returns an unmodifiable view of a required list. -
undefinedMap
public static <K, V> java.util.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(java.util.Map<K,V> map)Ismap
defined according to JSON/JavaScript semantics?- Returns:
- true if
map
is notnull
and notundefinedMap()
-
unmodifiable
public static <K, V> java.util.Map<K,V> unmodifiable(java.util.Map<K,V> map) -
unmodifiableRequired
public static <K, V> java.util.Map<K,V> unmodifiableRequired(java.util.Map<K,V> map, java.lang.Object obj, java.lang.String name)Returns an unmodifiable view of a required map.
-