public class KubernetesSerialization extends Object
Constructor and Description |
---|
KubernetesSerialization()
Creates a new instance with a fresh ObjectMapper
|
KubernetesSerialization(com.fasterxml.jackson.databind.ObjectMapper mapper,
boolean searchClassloaders)
Creates a new instance with the given ObjectMapper, which will be configured for use for
kubernetes resource serialization / deserialization.
|
Modifier and Type | Method and Description |
---|---|
<T> String |
asJson(T object)
Returns a JSON representation of the given object.
|
<T> String |
asYaml(T object)
Returns a YAML representation of the given object.
|
<T> T |
clone(T resource)
Create a copy of the resource via serialization.
|
protected void |
configureMapper(com.fasterxml.jackson.databind.ObjectMapper mapper) |
Type |
constructParametricType(Class<?> parameterizedClass,
Class<?>... parameterClasses) |
String |
convertToJson(String input) |
<T> T |
convertValue(Object value,
Class<T> type) |
Class<? extends io.fabric8.kubernetes.api.model.KubernetesResource> |
getRegisteredKubernetesResource(String apiVersion,
String kind) |
io.fabric8.kubernetes.model.jackson.UnmatchedFieldTypeModule |
getUnmatchedFieldTypeModule() |
void |
registerKubernetesResource(Class<? extends io.fabric8.kubernetes.api.model.KubernetesResource> clazz)
Registers a new resource, which can then be recognized for deserialization
|
void |
registerKubernetesResource(String apiVersion,
String kind,
Class<? extends io.fabric8.kubernetes.api.model.KubernetesResource> clazz)
Registers a new resource, which can then be recognized for deserialization.
|
<T> T |
unmarshal(InputStream is)
Unmarshals a stream.
|
<T> T |
unmarshal(InputStream is,
Class<T> type)
Unmarshals an
InputStream . |
<T> T |
unmarshal(InputStream is,
com.fasterxml.jackson.core.type.TypeReference<T> type) |
<T> T |
unmarshal(String str)
Unmarshals a
String |
<T> T |
unmarshal(String str,
Class<T> type)
Unmarshals a
String |
public KubernetesSerialization()
public KubernetesSerialization(com.fasterxml.jackson.databind.ObjectMapper mapper, boolean searchClassloaders)
searchClassloaders
- if KubernetesResource
should be automatically discovered via ServiceLoader
protected void configureMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
public <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 <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 <T> T unmarshal(InputStream is)
The type is assumed to be KubernetesResource
T
- The target type.is
- The InputStream
.public <T> T unmarshal(InputStream is, com.fasterxml.jackson.core.type.TypeReference<T> type)
public <T> T unmarshal(String str)
String
The type is assumed to be KubernetesResource
T
- template argument denoting typestr
- The String
.public <T> T unmarshal(String str, Class<T> type)
String
T
- template argument denoting typestr
- The String
.type
- The target type.public <T> T unmarshal(InputStream is, Class<T> type)
InputStream
.T
- Template argument denoting typeis
- The InputStream
.type
- The type.public <T> T clone(T resource)
IllegalArgumentException
- if the cloning cannot be performedpublic Type constructParametricType(Class<?> parameterizedClass, Class<?>... parameterClasses)
public Class<? extends io.fabric8.kubernetes.api.model.KubernetesResource> getRegisteredKubernetesResource(String apiVersion, String kind)
public io.fabric8.kubernetes.model.jackson.UnmatchedFieldTypeModule getUnmatchedFieldTypeModule()
public void registerKubernetesResource(Class<? extends io.fabric8.kubernetes.api.model.KubernetesResource> clazz)
public void registerKubernetesResource(String apiVersion, String kind, Class<? extends io.fabric8.kubernetes.api.model.KubernetesResource> clazz)
This is for advanced usage scenarios where you have a class that lacks annotations, or you can have the same class represent multiple versions or groups. However the DSL won't work with those classes - the resource(Class) method and other DSL logic only consults annotations via static HasMetadata methods.
Copyright © 2015–2024 Red Hat. All rights reserved.