-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2923 from yue9944882/regen-1.28
Regenerate from k8s 1.28 using v4.3.1 generator
- Loading branch information
Showing
2,346 changed files
with
172,969 additions
and
171,630 deletions.
There are no files selected for viewing
135 changes: 43 additions & 92 deletions
135
fluent/src/main/java/io/kubernetes/client/fluent/BaseFluent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
7
fluent/src/main/java/io/kubernetes/client/fluent/Builder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
fluent/src/main/java/io/kubernetes/client/fluent/Editable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.