io.yupiik.kubernetes.bindings.v1_23_2.v1.APIResource Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2022 - Yupiik SAS - https://www.yupiik.com
* 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.yupiik.kubernetes.bindings.v1_23_2.v1;
import io.yupiik.kubernetes.bindings.v1_23_2.Exportable;
import io.yupiik.kubernetes.bindings.v1_23_2.JsonStrings;
import io.yupiik.kubernetes.bindings.v1_23_2.Validable;
import io.yupiik.kubernetes.bindings.v1_23_2.ValidationException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
import static java.util.stream.Collectors.joining;
public class APIResource implements Validable, Exportable {
private List categories;
private String group;
private String kind;
private String name;
private boolean namespaced;
private List shortNames;
private String singularName;
private String storageVersionHash;
private List verbs;
private String version;
public APIResource() {
// no-op
}
public APIResource(final List categories,
final String group,
final String kind,
final String name,
final boolean namespaced,
final List shortNames,
final String singularName,
final String storageVersionHash,
final List verbs,
final String version) {
this.categories = categories;
this.group = group;
this.kind = kind;
this.name = name;
this.namespaced = namespaced;
this.shortNames = shortNames;
this.singularName = singularName;
this.storageVersionHash = storageVersionHash;
this.verbs = verbs;
this.version = version;
}
public List getCategories() {
return categories;
}
public void setCategories(final List categories) {
this.categories = categories;
}
public String getGroup() {
return group;
}
public void setGroup(final String group) {
this.group = group;
}
public String getKind() {
return kind;
}
public void setKind(final String kind) {
this.kind = kind;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public boolean getNamespaced() {
return namespaced;
}
public void setNamespaced(final boolean namespaced) {
this.namespaced = namespaced;
}
public List getShortNames() {
return shortNames;
}
public void setShortNames(final List shortNames) {
this.shortNames = shortNames;
}
public String getSingularName() {
return singularName;
}
public void setSingularName(final String singularName) {
this.singularName = singularName;
}
public String getStorageVersionHash() {
return storageVersionHash;
}
public void setStorageVersionHash(final String storageVersionHash) {
this.storageVersionHash = storageVersionHash;
}
public List getVerbs() {
return verbs;
}
public void setVerbs(final List verbs) {
this.verbs = verbs;
}
public String getVersion() {
return version;
}
public void setVersion(final String version) {
this.version = version;
}
@Override
public int hashCode() {
return Objects.hash(
categories,
group,
kind,
name,
namespaced,
shortNames,
singularName,
storageVersionHash,
verbs,
version);
}
@Override
public boolean equals(final Object __other) {
if (!(__other instanceof APIResource)) {
return false;
}
final APIResource __otherCasted = (APIResource) __other;
return Objects.equals(categories, __otherCasted.categories) &&
Objects.equals(group, __otherCasted.group) &&
Objects.equals(kind, __otherCasted.kind) &&
Objects.equals(name, __otherCasted.name) &&
Objects.equals(namespaced, __otherCasted.namespaced) &&
Objects.equals(shortNames, __otherCasted.shortNames) &&
Objects.equals(singularName, __otherCasted.singularName) &&
Objects.equals(storageVersionHash, __otherCasted.storageVersionHash) &&
Objects.equals(verbs, __otherCasted.verbs) &&
Objects.equals(version, __otherCasted.version);
}
public APIResource categories(final List categories) {
this.categories = categories;
return this;
}
public APIResource group(final String group) {
this.group = group;
return this;
}
public APIResource kind(final String kind) {
this.kind = kind;
return this;
}
public APIResource name(final String name) {
this.name = name;
return this;
}
public APIResource namespaced(final boolean namespaced) {
this.namespaced = namespaced;
return this;
}
public APIResource shortNames(final List shortNames) {
this.shortNames = shortNames;
return this;
}
public APIResource singularName(final String singularName) {
this.singularName = singularName;
return this;
}
public APIResource storageVersionHash(final String storageVersionHash) {
this.storageVersionHash = storageVersionHash;
return this;
}
public APIResource verbs(final List verbs) {
this.verbs = verbs;
return this;
}
public APIResource version(final String version) {
this.version = version;
return this;
}
@Override
public APIResource validate() {
List __errors_jsonSchema = null;
if (kind == null) {
if (__errors_jsonSchema == null) {
__errors_jsonSchema = new ArrayList<>();
}
__errors_jsonSchema.add(new ValidationException.ValidationError(
"kind", "kind",
"Missing 'kind' attribute.", true));
}
if (name == null) {
if (__errors_jsonSchema == null) {
__errors_jsonSchema = new ArrayList<>();
}
__errors_jsonSchema.add(new ValidationException.ValidationError(
"name", "name",
"Missing 'name' attribute.", true));
}
if (singularName == null) {
if (__errors_jsonSchema == null) {
__errors_jsonSchema = new ArrayList<>();
}
__errors_jsonSchema.add(new ValidationException.ValidationError(
"singularName", "singularName",
"Missing 'singularName' attribute.", true));
}
if (verbs == null) {
if (__errors_jsonSchema == null) {
__errors_jsonSchema = new ArrayList<>();
}
__errors_jsonSchema.add(new ValidationException.ValidationError(
"verbs", "verbs",
"Missing 'verbs' attribute.", true));
}
if (__errors_jsonSchema != null) {
throw new ValidationException(__errors_jsonSchema);
}
return this;
}
@Override
public String asJson() {
return Stream.of(
(categories != null ? "\"categories\":" + categories.stream().map(__it -> __it == null ? "null" : ("\"" + JsonStrings.escapeJson(__it) + "\"")).collect(joining(",", "[", "]")) : ""),
(group != null ? "\"group\":\"" + JsonStrings.escapeJson(group) + "\"" : ""),
(kind != null ? "\"kind\":\"" + JsonStrings.escapeJson(kind) + "\"" : ""),
(name != null ? "\"name\":\"" + JsonStrings.escapeJson(name) + "\"" : ""),
"\"namespaced\":" + namespaced,
(shortNames != null ? "\"shortNames\":" + shortNames.stream().map(__it -> __it == null ? "null" : ("\"" + JsonStrings.escapeJson(__it) + "\"")).collect(joining(",", "[", "]")) : ""),
(singularName != null ? "\"singularName\":\"" + JsonStrings.escapeJson(singularName) + "\"" : ""),
(storageVersionHash != null ? "\"storageVersionHash\":\"" + JsonStrings.escapeJson(storageVersionHash) + "\"" : ""),
(verbs != null ? "\"verbs\":" + verbs.stream().map(__it -> __it == null ? "null" : ("\"" + JsonStrings.escapeJson(__it) + "\"")).collect(joining(",", "[", "]")) : ""),
(version != null ? "\"version\":\"" + JsonStrings.escapeJson(version) + "\"" : ""))
.filter(__it -> !__it.isBlank())
.collect(joining(",", "{", "}"));
}
}