io.kubernetes.client.fluent.BaseFluent Maven / Gradle / Ivy
package io.kubernetes.client.fluent;
import java.util.LinkedHashSet;
import java.util.stream.Collectors;
import java.util.Set;
import java.util.Optional;
import java.util.ArrayList;
import java.util.Objects;
import java.lang.Object;
import java.util.List;
import java.lang.String;
import java.util.Arrays;
public class BaseFluent{
public static final String VISIT = "visit";
public final VisitableMap _visitables = new VisitableMap();
public static VisitableBuilder builderOf(T item) {
if (item instanceof Editable) {
Object editor = ((Editable) item).edit();
if (editor instanceof VisitableBuilder) {
return (VisitableBuilder) editor;
}
}
try {
return (VisitableBuilder) Class
.forName(item.getClass().getName() + "Builder", true, item.getClass().getClassLoader())
.getConstructor(item.getClass())
.newInstance(item);
} catch (Exception e) {
try {
return (VisitableBuilder) 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 List 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 Set build(Set extends io.kubernetes.client.fluent.Builder extends T>> set) {
return set == null ? null : new LinkedHashSet(set.stream().map(Builder::build).collect(Collectors.toSet()));
}
public static List aggregate(List extends T>... lists) {
return new ArrayList(Arrays.stream(lists).filter(Objects::nonNull).collect(Collectors.toList()));
}
public static Set aggregate(Set extends T>... sets) {
return new LinkedHashSet(Arrays.stream(sets).filter(Objects::nonNull).collect(Collectors.toSet()));
}
public Optional getVisitableMap() {
return Optional.of(_visitables);
}
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;
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy