Package org.opensearch.client.util
Class ApiTypeHelper
- java.lang.Object
-
- org.opensearch.client.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
All Methods Static Methods Concrete Methods 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>
booleanisDefined(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.
-
-
-
Method Detail
-
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.
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.
-
-