io.yupiik.kubernetes.bindings.v1_23_5.v1beta1.PolicyRulesWithSubjects 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_5.v1beta1;
import io.yupiik.kubernetes.bindings.v1_23_5.Exportable;
import io.yupiik.kubernetes.bindings.v1_23_5.Validable;
import io.yupiik.kubernetes.bindings.v1_23_5.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 PolicyRulesWithSubjects implements Validable, Exportable {
private List nonResourceRules;
private List resourceRules;
private List subjects;
public PolicyRulesWithSubjects() {
// no-op
}
public PolicyRulesWithSubjects(final List nonResourceRules,
final List resourceRules,
final List subjects) {
this.nonResourceRules = nonResourceRules;
this.resourceRules = resourceRules;
this.subjects = subjects;
}
public List getNonResourceRules() {
return nonResourceRules;
}
public void setNonResourceRules(final List nonResourceRules) {
this.nonResourceRules = nonResourceRules;
}
public List getResourceRules() {
return resourceRules;
}
public void setResourceRules(final List resourceRules) {
this.resourceRules = resourceRules;
}
public List getSubjects() {
return subjects;
}
public void setSubjects(final List subjects) {
this.subjects = subjects;
}
@Override
public int hashCode() {
return Objects.hash(
nonResourceRules,
resourceRules,
subjects);
}
@Override
public boolean equals(final Object __other) {
if (!(__other instanceof PolicyRulesWithSubjects)) {
return false;
}
final PolicyRulesWithSubjects __otherCasted = (PolicyRulesWithSubjects) __other;
return Objects.equals(nonResourceRules, __otherCasted.nonResourceRules) &&
Objects.equals(resourceRules, __otherCasted.resourceRules) &&
Objects.equals(subjects, __otherCasted.subjects);
}
public PolicyRulesWithSubjects nonResourceRules(final List nonResourceRules) {
this.nonResourceRules = nonResourceRules;
return this;
}
public PolicyRulesWithSubjects resourceRules(final List resourceRules) {
this.resourceRules = resourceRules;
return this;
}
public PolicyRulesWithSubjects subjects(final List subjects) {
this.subjects = subjects;
return this;
}
@Override
public PolicyRulesWithSubjects validate() {
List __errors_jsonSchema = null;
if (subjects == null) {
if (__errors_jsonSchema == null) {
__errors_jsonSchema = new ArrayList<>();
}
__errors_jsonSchema.add(new ValidationException.ValidationError(
"subjects", "subjects",
"Missing 'subjects' attribute.", true));
}
if (__errors_jsonSchema != null) {
throw new ValidationException(__errors_jsonSchema);
}
return this;
}
@Override
public String asJson() {
return Stream.of(
(nonResourceRules != null ? "\"nonResourceRules\":" + nonResourceRules.stream().map(__it -> __it == null ? "null" : __it.asJson()).collect(joining(",", "[", "]")) : ""),
(resourceRules != null ? "\"resourceRules\":" + resourceRules.stream().map(__it -> __it == null ? "null" : __it.asJson()).collect(joining(",", "[", "]")) : ""),
(subjects != null ? "\"subjects\":" + subjects.stream().map(__it -> __it == null ? "null" : __it.asJson()).collect(joining(",", "[", "]")) : ""))
.filter(__it -> !__it.isBlank())
.collect(joining(",", "{", "}"));
}
}