Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
Copyright 2020 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package io.kubernetes.client.util;
import com.google.gson.annotations.SerializedName;
import io.kubernetes.client.common.KubernetesType;
import io.kubernetes.client.custom.IntOrString;
import io.kubernetes.client.custom.Quantity;
import io.kubernetes.client.openapi.models.V1JSONSchemaProps;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import okio.ByteString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.TypeDescription;
import org.yaml.snakeyaml.constructor.BaseConstructor;
import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.introspector.Property;
import org.yaml.snakeyaml.nodes.MappingNode;
import org.yaml.snakeyaml.nodes.Node;
import org.yaml.snakeyaml.nodes.NodeTuple;
import org.yaml.snakeyaml.nodes.ScalarNode;
import org.yaml.snakeyaml.nodes.Tag;
import org.yaml.snakeyaml.representer.Represent;
import org.yaml.snakeyaml.representer.Representer;
/** The type Yaml. */
public class Yaml {
static final Logger logger = LoggerFactory.getLogger(Yaml.class);
/**
* Load an API object from a YAML string representation. Returns a concrete typed object (e.g.
* V1Pod)
*
* @param content The YAML content
* @return An instantiation of the object.
* @throws IOException If an error occurs while reading the YAML.
*/
public static Object load(String content) throws IOException {
return load(new StringReader(content));
}
/**
* Load an API object from a YAML file. Returns a concrete typed object (e.g. V1Pod)
*
* @param f The file to load.
* @return An instantiation of the object.
* @throws IOException If an error occurs while reading the YAML.
*/
public static Object load(File f) throws IOException {
return load(new FileReader(f));
}
/**
* Load an API object from a stream of data. Returns a concrete typed object (e.g. V1Pod)
*
* @param reader The stream to load.
* @return An instantiation of the object.
* @throws IOException If an error occurs while reading the YAML.
*/
public static Object load(Reader reader) throws IOException {
Map data = getSnakeYaml(null).load(reader);
return modelMapper(data);
}
/**
* Load an API object from a YAML string representation. Returns a concrete typed object using the
* type specified.
*
* @param content The YAML content
* @param clazz The class of object to return.
* @return An instantiation of the object.
* @throws IOException If an error occurs while reading the YAML.
*/
public static T loadAs(String content, Class clazz) {
return getSnakeYaml(clazz).loadAs(new StringReader(content), clazz);
}
/**
* Load an API object from a YAML file. Returns a concrete typed object using the type specified.
*
* @param f The YAML file
* @param clazz The class of object to return.
* @return An instantiation of the object.
* @throws IOException If an error occurs while reading the YAML.
*/
public static T loadAs(File f, Class clazz) throws IOException {
return getSnakeYaml(clazz).loadAs(new FileReader(f), clazz);
}
/**
* Load an API object from a YAML stream. Returns a concrete typed object using the type
* specified.
*
* @param reader The YAML stream
* @param clazz The class of object to return.
* @return An instantiation of the object.
* @throws IOException If an error occurs while reading the YAML.
*/
public static T loadAs(Reader reader, Class clazz) {
return getSnakeYaml(clazz).loadAs(reader, clazz);
}
/**
* Load list of instantiated API objects from a YAML string representation. Returns list of
* concrete typed objects (e.g. { V1Pod, V1SERVICE })
*
*
Order of API objects in list will be preserved according to order of objects in YAML string.
*
* @param content The YAML content
* @return List of instantiated objects.
* @throws IOException If an error occurs while reading the YAML.
*/
public static List