public class Serialization extends Object
| Modifier and Type | Field and Description |
|---|---|
static io.fabric8.kubernetes.model.jackson.UnmatchedFieldTypeModule |
UNMATCHED_FIELD_TYPE_MODULE |
| Modifier and Type | Method and Description |
|---|---|
static <T> String |
asJson(T object)
Returns a JSON representation of the given object.
|
static <T> String |
asYaml(T object)
Returns a YAML representation of the given object.
|
static void |
clearYamlMapper()
Deprecated.
to be removed in later versions
|
static <T> T |
clone(T resource)
Create a copy of the resource via serialization.
|
static com.fasterxml.jackson.databind.ObjectMapper |
jsonMapper()
ObjectMapper singleton instance used internally by the Kubernetes client. |
static <T> T |
unmarshal(InputStream is)
Unmarshals a stream.
|
static <T> T |
unmarshal(InputStream is,
Class<T> type)
Unmarshals an
InputStream. |
static <T> T |
unmarshal(InputStream is,
Class<T> type,
Map<String,String> parameters)
Deprecated.
please directly apply
Utils.interpolateString(String, Map) instead of passing parameters here |
static <T> T |
unmarshal(InputStream is,
Map<String,String> parameters)
Deprecated.
please directly apply
Utils.interpolateString(String, Map) instead of passing parameters here |
static <T> T |
unmarshal(InputStream is,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Unmarshals a stream.
|
static <T> T |
unmarshal(InputStream is,
com.fasterxml.jackson.databind.ObjectMapper mapper,
Map<String,String> parameters)
Deprecated.
please directly apply
Utils.interpolateString(String, Map) instead of passing parameters here |
static <T> T |
unmarshal(InputStream is,
com.fasterxml.jackson.core.type.TypeReference<T> type)
Unmarshals an
InputStream. |
static <T> T |
unmarshal(InputStream is,
com.fasterxml.jackson.core.type.TypeReference<T> type,
Map<String,String> parameters)
Deprecated.
please directly apply
Utils.interpolateString(String, Map) instead of passing parameters here |
static <T> T |
unmarshal(String str)
Unmarshals a
String |
static <T> T |
unmarshal(String str,
Class<T> type)
Unmarshals a
String |
static <T> T |
unmarshal(String str,
Class<T> type,
Map<String,String> parameters)
Deprecated.
please directly apply
Utils.interpolateString(String, Map) instead of passing parameters here |
static com.fasterxml.jackson.databind.ObjectMapper |
yamlMapper()
Deprecated.
use
asYaml(Object) or one of the unmarshal methods |
public static final io.fabric8.kubernetes.model.jackson.UnmatchedFieldTypeModule UNMATCHED_FIELD_TYPE_MODULE
public static com.fasterxml.jackson.databind.ObjectMapper jsonMapper()
ObjectMapper singleton instance used internally by the Kubernetes client.
The ObjectMapper has an UnmatchedFieldTypeModule module registered. This module allows the client
to work with Resources that contain properties that don't match the target field type. This is especially useful
and necessary to work with OpenShift Templates.
n.b. the use of this module gives precedence to properties present in the additionalProperties Map present in most KubernetesResource instances. If a property is both defined in the Map and in the original field, the one from the additionalProperties Map will be serialized.
@Deprecated public static com.fasterxml.jackson.databind.ObjectMapper yamlMapper()
asYaml(Object) or one of the unmarshal methodsObjectMapper singleton instance used internally by the Kubernetes client.
The ObjectMapper has an UnmatchedFieldTypeModule module registered. This module allows the client
to work with Resources that contain properties that don't match the target field type. This is especially useful
and necessary to work with OpenShift Templates.
n.b. the use of this module gives precedence to properties present in the additionalProperties Map present in most KubernetesResource instances. If a property is both defined in the Map and in the original field, the one from the additionalProperties Map will be serialized.
@Deprecated public static void clearYamlMapper()
public static <T> String asJson(T object)
If the provided object contains a JsonAnyGetter annotated method with a Map that contains an entry that overrides a field of the provided object, the Map entry will take precedence upon serialization. Properties won't be duplicated.
T - the type of the object being serialized.object - the object to serialize.public static <T> String asYaml(T object)
If the provided object contains a JsonAnyGetter annotated method with a Map that contains an entry that overrides a field of the provided object, the Map entry will take precedence upon serialization. Properties won't be duplicated.
T - the type of the object being serialized.object - the object to serialize.public static <T> T unmarshal(InputStream is)
The type is assumed to be KubernetesResource
T - The target type.is - The InputStream.@Deprecated public static <T> T unmarshal(InputStream is, Map<String,String> parameters)
Utils.interpolateString(String, Map) instead of passing parameters here
The type is assumed to be KubernetesResource
T - The target type.is - The InputStream.parameters - A Map with parameters for placeholder substitution.public static <T> T unmarshal(InputStream is, com.fasterxml.jackson.databind.ObjectMapper mapper)
The type is assumed to be KubernetesResource
T - The target type.is - The InputStream.mapper - The ObjectMapper to use.@Deprecated public static <T> T unmarshal(InputStream is, com.fasterxml.jackson.databind.ObjectMapper mapper, Map<String,String> parameters)
Utils.interpolateString(String, Map) instead of passing parameters here
The type is assumed to be KubernetesResource
T - The target type.is - The InputStream.mapper - The ObjectMapper to use.parameters - A Map with parameters for placeholder substitution.public static <T> T unmarshal(String str)
String
The type is assumed to be KubernetesResource
T - template argument denoting typestr - The String.public static <T> T unmarshal(String str, Class<T> type)
StringT - template argument denoting typestr - The String.type - The target type.@Deprecated public static <T> T unmarshal(String str, Class<T> type, Map<String,String> parameters)
Utils.interpolateString(String, Map) instead of passing parameters hereString optionally performing placeholder substitution to the String.T - Template argument denoting typestr - The String.type - The target type.parameters - A hashmap containing parameterspublic static <T> T unmarshal(InputStream is, Class<T> type)
InputStream.T - Template argument denoting typeis - The InputStream.type - The type.@Deprecated public static <T> T unmarshal(InputStream is, Class<T> type, Map<String,String> parameters)
Utils.interpolateString(String, Map) instead of passing parameters hereInputStream optionally performing placeholder substitution to the stream.T - Template argument denoting typeis - The InputStream.type - The type.parameters - A Map with parameters for placeholder substitution.public static <T> T unmarshal(InputStream is, com.fasterxml.jackson.core.type.TypeReference<T> type)
InputStream.T - Template argument denoting typeis - The InputStream.type - The TypeReference.@Deprecated public static <T> T unmarshal(InputStream is, com.fasterxml.jackson.core.type.TypeReference<T> type, Map<String,String> parameters)
Utils.interpolateString(String, Map) instead of passing parameters hereInputStream optionally performing placeholder substitution to the stream.T - Template argument denoting typeis - The InputStream.type - The TypeReference.parameters - A Map with parameters for placeholder substitution.public static <T> T clone(T resource)
IllegalArgumentException - if the cloning cannot be performedCopyright © 2015–2023 Red Hat. All rights reserved.