Skip to content

Commit

Permalink
Automated openapi generation from release-1.25
Browse files Browse the repository at this point in the history
Signed-off-by: Kubernetes Prow Robot <[email protected]>
  • Loading branch information
Kubernetes Prow Robot committed Dec 5, 2022
1 parent ce32410 commit c891da7
Show file tree
Hide file tree
Showing 2,042 changed files with 46,540 additions and 141,151 deletions.
170 changes: 63 additions & 107 deletions fluent/src/main/java/io/kubernetes/client/fluent/BaseFluent.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,22 @@
/*
Copyright 2022 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.fluent;

import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

public class BaseFluent<F extends Fluent<F>> implements Fluent<F>, Visitable<F> {
import java.util.Set;
import java.util.ArrayList;
import java.lang.String;
import java.util.AbstractMap;
import java.util.Objects;
import java.lang.Class;
import java.lang.Object;
import java.util.List;
import java.util.Arrays;
import java.util.Collections;
public class BaseFluent<F extends Fluent<F>> implements Fluent<F>,Visitable<F>{
public static final String VISIT = "visit";
public final VisitableMap _visitables = new VisitableMap();

public static <T> VisitableBuilder<T, ?> builderOf(T item) {
public static <T>VisitableBuilder<T,?> builderOf(T item) {
if (item instanceof Editable) {
Object editor = ((Editable) item).edit();
if (editor instanceof VisitableBuilder) {
Expand All @@ -36,122 +25,89 @@ public class BaseFluent<F extends Fluent<F>> implements Fluent<F>, Visitable<F>
}

try {
return (VisitableBuilder<T, ?>)
Class.forName(item.getClass().getName() + "Builder")
.getConstructor(item.getClass())
.newInstance(item);
return (VisitableBuilder<T, ?>) Class.forName(item.getClass().getName() + "Builder").getConstructor(item.getClass())
.newInstance(item);
} catch (Exception e) {
throw new IllegalStateException("Failed to create builder for: " + item.getClass(), e);
}
}

public static <T> List<T> build(
List<? extends io.kubernetes.client.fluent.Builder<? extends T>> list) {
return list == null
? null
: new ArrayList<T>(list.stream().map(Builder::build).collect(Collectors.toList()));
public static <T>List<T> build(List<? extends io.kubernetes.client.fluent.Builder<? extends T>> list) {
return list == null ? null : new ArrayList<T>(list.stream().map(Builder::build).collect(Collectors.toList()));
}

public static <T> Set<T> build(
Set<? extends io.kubernetes.client.fluent.Builder<? extends T>> set) {
return set == null
? null
: new LinkedHashSet<T>(set.stream().map(Builder::build).collect(Collectors.toSet()));
public static <T>Set<T> build(Set<? extends io.kubernetes.client.fluent.Builder<? extends T>> set) {
return set == null ? null : new LinkedHashSet<T>(set.stream().map(Builder::build).collect(Collectors.toSet()));
}

public static <T> List<T> aggregate(List<? extends T>... lists) {
return new ArrayList(
Arrays.stream(lists).filter(Objects::nonNull).collect(Collectors.toList()));
public static <T>List<T> aggregate(List<? extends T>... lists) {
return new ArrayList(Arrays.stream(lists).filter(Objects::nonNull).collect(Collectors.toList()));
}

public static <T> Set<T> aggregate(Set<? extends T>... sets) {
return new LinkedHashSet(
Arrays.stream(sets).filter(Objects::nonNull).collect(Collectors.toSet()));
public static <T>Set<T> aggregate(Set<? extends T>... sets) {
return new LinkedHashSet(Arrays.stream(sets).filter(Objects::nonNull).collect(Collectors.toSet()));
}

public F accept(io.kubernetes.client.fluent.Visitor... visitors) {
return accept(Collections.emptyList(), visitors);
}
public <V>F accept(Class<V> type,Visitor<V> visitor) {
return accept(Collections.emptyList(), new Visitor<V>() {
@Override
public Class<V> getType() {
return type;
}

public <V> F accept(Class<V> type, Visitor<V> visitor) {
return accept(
Collections.emptyList(),
new Visitor<V>() {
@Override
public Class<V> getType() {
return type;
}

@Override
public void visit(List<Entry<String, Object>> path, V element) {
visitor.visit(path, element);
}
@Override
public void visit(List<Entry<String, Object>> path, V element) {
visitor.visit(path, element);
}

@Override
public void visit(V element) {
visitor.visit(element);
}
});
@Override
public void visit(V element) {
visitor.visit(element);
}
});
}

public F accept(
List<Entry<String, Object>> path, io.kubernetes.client.fluent.Visitor... visitors) {
public F accept(List<Entry<String,Object>> path,io.kubernetes.client.fluent.Visitor... visitors) {
return accept(path, "", visitors);
}

public F accept(
List<Entry<String, Object>> path,
String currentKey,
io.kubernetes.client.fluent.Visitor... visitors) {
public F accept(List<Entry<String,Object>> path,String currentKey,io.kubernetes.client.fluent.Visitor... visitors) {
Arrays.stream(visitors)
.map(v -> VisitorListener.wrap(v))
.filter(v -> ((Visitor) v).canVisit(path, this))
.sorted((l, r) -> ((Visitor) r).order() - ((Visitor) l).order())
.forEach(
v -> {
((Visitor) v).visit(path, this);
});
.forEach(v -> {
((Visitor) v).visit(path, this);
});

List<Entry<String, Object>> copyOfPath = path != null ? new ArrayList(path) : new ArrayList<>();
copyOfPath.add(new AbstractMap.SimpleEntry<String, Object>(currentKey, this));

_visitables.forEach(
(key, visitables) -> {
List<Entry<String, Object>> newPath = Collections.unmodifiableList(copyOfPath);
// Copy visitables to avoid ConcurrrentModificationException when Visitors add/remove
// Visitables
new ArrayList<>(visitables)
.forEach(
visitable -> {
Arrays.stream(visitors)
.filter(
v ->
v.getType() != null
&& v.getType().isAssignableFrom(visitable.getClass()))
.forEach(v -> visitable.accept(newPath, key, v));

Arrays.stream(visitors)
.filter(
v ->
v.getType() == null
|| !v.getType().isAssignableFrom(visitable.getClass()))
.forEach(v -> visitable.accept(newPath, key, v));
});
});
_visitables.forEach((key, visitables) -> {
List<Entry<String, Object>> newPath = Collections.unmodifiableList(copyOfPath);
// Copy visitables to avoid ConcurrrentModificationException when Visitors add/remove Visitables
new ArrayList<>(visitables).forEach(visitable -> {
Arrays.stream(visitors)
.filter(v -> v.getType() != null && v.getType().isAssignableFrom(visitable.getClass()))
.forEach(v -> visitable.accept(newPath, key, v));

Arrays.stream(visitors)
.filter(v -> v.getType() == null || !v.getType().isAssignableFrom(visitable.getClass()))
.forEach(v -> visitable.accept(newPath, key, v));
});
});
return (F) this;
}

public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + 0;
return result;
}

public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return true;
}
}

}
20 changes: 5 additions & 15 deletions fluent/src/main/java/io/kubernetes/client/fluent/Builder.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
/*
Copyright 2022 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.fluent;

@FunctionalInterface
public interface Builder<T> {
import java.lang.FunctionalInterface;
@FunctionalInterface
public interface Builder<T>{
T build();
}

}
Original file line number Diff line number Diff line change
@@ -1,47 +1,32 @@
/*
Copyright 2022 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.fluent;

import java.util.List;
import java.util.Map.Entry;
import java.lang.Class;
import java.lang.Object;
import java.util.List;
import java.lang.String;
import java.util.function.Predicate;

public class DelegatingVisitor<T> implements Visitor<T> {
DelegatingVisitor(Class<T> type, Visitor<T> delegate) {
public class DelegatingVisitor<T> implements Visitor<T>{
DelegatingVisitor(Class<T> type,Visitor<T> delegate) {
this.type = type;
this.delegate = delegate;
}

private final Class<T> type;
private final Visitor<T> delegate;

public Class<T> getType() {
return type;
}

public void visit(T target) {
delegate.visit(target);
}

public int order() {
return delegate.order();
}

public void visit(List<Entry<String, Object>> path, T target) {
public void visit(List<Entry<String,Object>> path,T target) {
delegate.visit(path, target);
}

public <F> Predicate<List<Entry<String, Object>>> getRequirement() {
public <F>Predicate<List<Entry<String,Object>>> getRequirement() {
return delegate.getRequirement();
}
}

}
17 changes: 3 additions & 14 deletions fluent/src/main/java/io/kubernetes/client/fluent/Editable.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/*
Copyright 2022 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.fluent;

public interface Editable<T> {
public interface Editable<T>{
T edit();
}

}
16 changes: 3 additions & 13 deletions fluent/src/main/java/io/kubernetes/client/fluent/Fluent.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
/*
Copyright 2022 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.fluent;

public interface Fluent<F extends Fluent<F>> {}
public interface Fluent<F extends Fluent<F>>{

}
17 changes: 3 additions & 14 deletions fluent/src/main/java/io/kubernetes/client/fluent/Nested.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/*
Copyright 2022 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.fluent;

public interface Nested<F> {
public interface Nested<F>{
F and();
}

}
Loading

0 comments on commit c891da7

Please sign in to comment.