Skip to content

Commit

Permalink
Merge pull request #2923 from yue9944882/regen-1.28
Browse files Browse the repository at this point in the history
Regenerate from k8s 1.28 using v4.3.1 generator
  • Loading branch information
k8s-ci-robot authored Dec 2, 2023
2 parents 5dc9db8 + 2b33104 commit a34b9e7
Show file tree
Hide file tree
Showing 2,346 changed files with 172,969 additions and 171,630 deletions.
135 changes: 43 additions & 92 deletions fluent/src/main/java/io/kubernetes/client/fluent/BaseFluent.java
Original file line number Diff line number Diff line change
@@ -1,128 +1,79 @@
package io.kubernetes.client.fluent;

import java.util.LinkedHashSet;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.Set;
import java.util.Optional;
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.lang.String;
import java.util.Arrays;
import java.util.Collections;
public class BaseFluent<F extends Fluent<F>> implements Fluent<F>,Visitable<F>{
public class BaseFluent<F>{
public static final String VISIT = "visit";
public final VisitableMap _visitables = new VisitableMap();

public static <T>VisitableBuilder<T,?> builderOf(T item) {
if (item instanceof Editable) {
Object editor = ((Editable) item).edit();
if (editor instanceof VisitableBuilder) {
return (VisitableBuilder<T, ?>) editor;
}
}

try {
return (VisitableBuilder<T, ?>) Class.forName(item.getClass().getName() + "Builder", true, item.getClass().getClassLoader()).getConstructor(item.getClass())
.newInstance(item);
} catch (Exception e) {
try {
return (VisitableBuilder<T, ?>) Class.forName(item.getClass().getName() + "Builder").getConstructor(item.getClass())
.newInstance(item);
} catch (Exception e1) {
throw new IllegalStateException("Failed to create builder for: " + item.getClass(), e1);
}
}
Object editor = ((Editable) item).edit();
if (editor instanceof VisitableBuilder) {
return (VisitableBuilder<T, ?>) editor;
}
}

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

public static <T>List<T> build(List<? extends io.kubernetes.client.fluent.Builder<? extends T>> list) {
return list == null ? null : 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>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 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;
}

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

@Override
public void visit(V element) {
visitor.visit(element);
}
});
}
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) {
List<Visitor> sortedVisitor = new ArrayList<>();
for (Visitor visitor : visitors) {
visitor = VisitorListener.wrap(visitor);
if (!visitor.canVisit(path, this)) {
continue;
}
sortedVisitor.add(visitor);
}
sortedVisitor.sort((l, r) -> ((Visitor) r).order() - ((Visitor) l).order());
for (Visitor visitor : sortedVisitor) {
visitor.visit(path, this);
}

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

for (Entry<String, ?> entry : _visitables.entrySet()) {
List<Entry<String, Object>> newPath = Collections.unmodifiableList(copyOfPath);

// Copy visitables to avoid ConcurrentModificationException when Visitors add/remove Visitables
for (Visitable<F> visitable : new ArrayList<>((List<Visitable<F>>) entry.getValue())) {
for (Visitor visitor : visitors) {
if (visitor.getType() != null && visitor.getType().isAssignableFrom(visitable.getClass())) {
visitable.accept(newPath, entry.getKey(), visitor);
}
}

for (Visitor visitor : visitors) {
if (visitor.getType() == null || !visitor.getType().isAssignableFrom(visitable.getClass())) {
visitable.accept(newPath, entry.getKey(), visitor);
}
}
}
}
return (F) this;

public Optional<VisitableMap> getVisitableMap() {
return Optional.of(_visitables);
}

public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + 0;
return result;
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;
return true;
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
return true;
}


}
7 changes: 5 additions & 2 deletions fluent/src/main/java/io/kubernetes/client/fluent/Builder.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package io.kubernetes.client.fluent;

import java.lang.FunctionalInterface;
@FunctionalInterface
public interface Builder<T>{
@FunctionalInterface
public interface Builder<T>{


T build();


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,30 @@
public class DelegatingVisitor<T> implements Visitor<T>{
DelegatingVisitor(Class<T> type,Visitor<T> delegate) {
this.type = type;
this.delegate = delegate;
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) {
delegate.visit(path, target);
}

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


}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package io.kubernetes.client.fluent;

public interface Editable<T>{


T edit();


}
5 changes: 0 additions & 5 deletions fluent/src/main/java/io/kubernetes/client/fluent/Fluent.java

This file was deleted.

3 changes: 3 additions & 0 deletions fluent/src/main/java/io/kubernetes/client/fluent/Nested.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package io.kubernetes.client.fluent;

public interface Nested<F>{


F and();


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,30 @@
public class PathAwareTypedVisitor<V,P> extends TypedVisitor<V>{
PathAwareTypedVisitor() {
List<Class> args = Visitors.getTypeArguments(PathAwareTypedVisitor.class, getClass());
if (args == null || args.isEmpty()) {
throw new IllegalStateException("Could not determine type arguments for path aware typed visitor.");
}
this.type = (Class<V>) args.get(0);
this.parentType = (Class<P>) args.get(1);
if (args == null || args.isEmpty()) {
throw new IllegalStateException("Could not determine type arguments for path aware typed visitor.");
}
this.type = (Class<V>) args.get(0);
this.parentType = (Class<P>) args.get(1);
}
private final Class<V> type;
private final Class<P> parentType;

public void visit(V element) {

}

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

public P getParent(List<Entry<String,Object>> path) {
return path.size() - 1 >= 0 ? (P) path.get(path.size() - 1) : null;
}

public Class<P> getParentType() {
return parentType;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

import java.lang.Class;
public abstract class TypedVisitor<V> implements Visitor<V>{



public Class<V> getType() {
return (Class<V>) Visitors.getTypeArguments(TypedVisitor.class, getClass()).get(0);
}


}
Loading

0 comments on commit a34b9e7

Please sign in to comment.