io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.HardwareDetailsFluent Maven / Gradle / Ivy
package io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1;
import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import java.lang.SuppressWarnings;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import java.util.LinkedHashMap;
import java.util.function.Predicate;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.lang.Integer;
import java.util.Collection;
import java.lang.Object;
import java.util.Map;
/**
* Generated
*/
@SuppressWarnings("unchecked")
public class HardwareDetailsFluent> extends BaseFluent{
public HardwareDetailsFluent() {
}
public HardwareDetailsFluent(HardwareDetails instance) {
this.copyInstance(instance);
}
private CPUBuilder cpu;
private FirmwareBuilder firmware;
private String hostname;
private ArrayList nics = new ArrayList();
private Integer ramMebibytes;
private ArrayList storage = new ArrayList();
private HardwareSystemVendorBuilder systemVendor;
private Map additionalProperties;
protected void copyInstance(HardwareDetails instance) {
instance = (instance != null ? instance : new HardwareDetails());
if (instance != null) {
this.withCpu(instance.getCpu());
this.withFirmware(instance.getFirmware());
this.withHostname(instance.getHostname());
this.withNics(instance.getNics());
this.withRamMebibytes(instance.getRamMebibytes());
this.withStorage(instance.getStorage());
this.withSystemVendor(instance.getSystemVendor());
this.withAdditionalProperties(instance.getAdditionalProperties());
}
}
public CPU buildCpu() {
return this.cpu != null ? this.cpu.build() : null;
}
public A withCpu(CPU cpu) {
this._visitables.remove("cpu");
if (cpu != null) {
this.cpu = new CPUBuilder(cpu);
this._visitables.get("cpu").add(this.cpu);
} else {
this.cpu = null;
this._visitables.get("cpu").remove(this.cpu);
}
return (A) this;
}
public boolean hasCpu() {
return this.cpu != null;
}
public CpuNested withNewCpu() {
return new CpuNested(null);
}
public CpuNested withNewCpuLike(CPU item) {
return new CpuNested(item);
}
public CpuNested editCpu() {
return withNewCpuLike(java.util.Optional.ofNullable(buildCpu()).orElse(null));
}
public CpuNested editOrNewCpu() {
return withNewCpuLike(java.util.Optional.ofNullable(buildCpu()).orElse(new CPUBuilder().build()));
}
public CpuNested editOrNewCpuLike(CPU item) {
return withNewCpuLike(java.util.Optional.ofNullable(buildCpu()).orElse(item));
}
public Firmware buildFirmware() {
return this.firmware != null ? this.firmware.build() : null;
}
public A withFirmware(Firmware firmware) {
this._visitables.remove("firmware");
if (firmware != null) {
this.firmware = new FirmwareBuilder(firmware);
this._visitables.get("firmware").add(this.firmware);
} else {
this.firmware = null;
this._visitables.get("firmware").remove(this.firmware);
}
return (A) this;
}
public boolean hasFirmware() {
return this.firmware != null;
}
public FirmwareNested withNewFirmware() {
return new FirmwareNested(null);
}
public FirmwareNested withNewFirmwareLike(Firmware item) {
return new FirmwareNested(item);
}
public FirmwareNested editFirmware() {
return withNewFirmwareLike(java.util.Optional.ofNullable(buildFirmware()).orElse(null));
}
public FirmwareNested editOrNewFirmware() {
return withNewFirmwareLike(java.util.Optional.ofNullable(buildFirmware()).orElse(new FirmwareBuilder().build()));
}
public FirmwareNested editOrNewFirmwareLike(Firmware item) {
return withNewFirmwareLike(java.util.Optional.ofNullable(buildFirmware()).orElse(item));
}
public String getHostname() {
return this.hostname;
}
public A withHostname(String hostname) {
this.hostname = hostname;
return (A) this;
}
public boolean hasHostname() {
return this.hostname != null;
}
public A addToNics(int index,NIC item) {
if (this.nics == null) {this.nics = new ArrayList();}
NICBuilder builder = new NICBuilder(item);
if (index < 0 || index >= nics.size()) { _visitables.get("nics").add(builder); nics.add(builder); } else { _visitables.get("nics").add(index, builder); nics.add(index, builder);}
return (A)this;
}
public A setToNics(int index,NIC item) {
if (this.nics == null) {this.nics = new ArrayList();}
NICBuilder builder = new NICBuilder(item);
if (index < 0 || index >= nics.size()) { _visitables.get("nics").add(builder); nics.add(builder); } else { _visitables.get("nics").set(index, builder); nics.set(index, builder);}
return (A)this;
}
public A addToNics(io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.NIC... items) {
if (this.nics == null) {this.nics = new ArrayList();}
for (NIC item : items) {NICBuilder builder = new NICBuilder(item);_visitables.get("nics").add(builder);this.nics.add(builder);} return (A)this;
}
public A addAllToNics(Collection items) {
if (this.nics == null) {this.nics = new ArrayList();}
for (NIC item : items) {NICBuilder builder = new NICBuilder(item);_visitables.get("nics").add(builder);this.nics.add(builder);} return (A)this;
}
public A removeFromNics(io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.NIC... items) {
if (this.nics == null) return (A)this;
for (NIC item : items) {NICBuilder builder = new NICBuilder(item);_visitables.get("nics").remove(builder); this.nics.remove(builder);} return (A)this;
}
public A removeAllFromNics(Collection items) {
if (this.nics == null) return (A)this;
for (NIC item : items) {NICBuilder builder = new NICBuilder(item);_visitables.get("nics").remove(builder); this.nics.remove(builder);} return (A)this;
}
public A removeMatchingFromNics(Predicate predicate) {
if (nics == null) return (A) this;
final Iterator each = nics.iterator();
final List visitables = _visitables.get("nics");
while (each.hasNext()) {
NICBuilder builder = each.next();
if (predicate.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public List buildNics() {
return this.nics != null ? build(nics) : null;
}
public NIC buildNic(int index) {
return this.nics.get(index).build();
}
public NIC buildFirstNic() {
return this.nics.get(0).build();
}
public NIC buildLastNic() {
return this.nics.get(nics.size() - 1).build();
}
public NIC buildMatchingNic(Predicate predicate) {
for (NICBuilder item : nics) {
if (predicate.test(item)) {
return item.build();
}
}
return null;
}
public boolean hasMatchingNic(Predicate predicate) {
for (NICBuilder item : nics) {
if (predicate.test(item)) {
return true;
}
}
return false;
}
public A withNics(List nics) {
if (this.nics != null) {
this._visitables.get("nics").clear();
}
if (nics != null) {
this.nics = new ArrayList();
for (NIC item : nics) {
this.addToNics(item);
}
} else {
this.nics = null;
}
return (A) this;
}
public A withNics(io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.NIC... nics) {
if (this.nics != null) {
this.nics.clear();
_visitables.remove("nics");
}
if (nics != null) {
for (NIC item : nics) {
this.addToNics(item);
}
}
return (A) this;
}
public boolean hasNics() {
return this.nics != null && !this.nics.isEmpty();
}
public NicsNested addNewNic() {
return new NicsNested(-1, null);
}
public NicsNested addNewNicLike(NIC item) {
return new NicsNested(-1, item);
}
public NicsNested setNewNicLike(int index,NIC item) {
return new NicsNested(index, item);
}
public NicsNested editNic(int index) {
if (nics.size() <= index) throw new RuntimeException("Can't edit nics. Index exceeds size.");
return setNewNicLike(index, buildNic(index));
}
public NicsNested editFirstNic() {
if (nics.size() == 0) throw new RuntimeException("Can't edit first nics. The list is empty.");
return setNewNicLike(0, buildNic(0));
}
public NicsNested editLastNic() {
int index = nics.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last nics. The list is empty.");
return setNewNicLike(index, buildNic(index));
}
public NicsNested editMatchingNic(Predicate predicate) {
int index = -1;
for (int i=0;i();}
StorageBuilder builder = new StorageBuilder(item);
if (index < 0 || index >= storage.size()) { _visitables.get("storage").add(builder); storage.add(builder); } else { _visitables.get("storage").add(index, builder); storage.add(index, builder);}
return (A)this;
}
public A setToStorage(int index,Storage item) {
if (this.storage == null) {this.storage = new ArrayList();}
StorageBuilder builder = new StorageBuilder(item);
if (index < 0 || index >= storage.size()) { _visitables.get("storage").add(builder); storage.add(builder); } else { _visitables.get("storage").set(index, builder); storage.set(index, builder);}
return (A)this;
}
public A addToStorage(io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.Storage... items) {
if (this.storage == null) {this.storage = new ArrayList();}
for (Storage item : items) {StorageBuilder builder = new StorageBuilder(item);_visitables.get("storage").add(builder);this.storage.add(builder);} return (A)this;
}
public A addAllToStorage(Collection items) {
if (this.storage == null) {this.storage = new ArrayList();}
for (Storage item : items) {StorageBuilder builder = new StorageBuilder(item);_visitables.get("storage").add(builder);this.storage.add(builder);} return (A)this;
}
public A removeFromStorage(io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.Storage... items) {
if (this.storage == null) return (A)this;
for (Storage item : items) {StorageBuilder builder = new StorageBuilder(item);_visitables.get("storage").remove(builder); this.storage.remove(builder);} return (A)this;
}
public A removeAllFromStorage(Collection items) {
if (this.storage == null) return (A)this;
for (Storage item : items) {StorageBuilder builder = new StorageBuilder(item);_visitables.get("storage").remove(builder); this.storage.remove(builder);} return (A)this;
}
public A removeMatchingFromStorage(Predicate predicate) {
if (storage == null) return (A) this;
final Iterator each = storage.iterator();
final List visitables = _visitables.get("storage");
while (each.hasNext()) {
StorageBuilder builder = each.next();
if (predicate.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public List buildStorage() {
return this.storage != null ? build(storage) : null;
}
public Storage buildStorage(int index) {
return this.storage.get(index).build();
}
public Storage buildFirstStorage() {
return this.storage.get(0).build();
}
public Storage buildLastStorage() {
return this.storage.get(storage.size() - 1).build();
}
public Storage buildMatchingStorage(Predicate predicate) {
for (StorageBuilder item : storage) {
if (predicate.test(item)) {
return item.build();
}
}
return null;
}
public boolean hasMatchingStorage(Predicate predicate) {
for (StorageBuilder item : storage) {
if (predicate.test(item)) {
return true;
}
}
return false;
}
public A withStorage(List storage) {
if (this.storage != null) {
this._visitables.get("storage").clear();
}
if (storage != null) {
this.storage = new ArrayList();
for (Storage item : storage) {
this.addToStorage(item);
}
} else {
this.storage = null;
}
return (A) this;
}
public A withStorage(io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.Storage... storage) {
if (this.storage != null) {
this.storage.clear();
_visitables.remove("storage");
}
if (storage != null) {
for (Storage item : storage) {
this.addToStorage(item);
}
}
return (A) this;
}
public boolean hasStorage() {
return this.storage != null && !this.storage.isEmpty();
}
public StorageNested addNewStorage() {
return new StorageNested(-1, null);
}
public StorageNested addNewStorageLike(Storage item) {
return new StorageNested(-1, item);
}
public StorageNested setNewStorageLike(int index,Storage item) {
return new StorageNested(index, item);
}
public StorageNested editStorage(int index) {
if (storage.size() <= index) throw new RuntimeException("Can't edit storage. Index exceeds size.");
return setNewStorageLike(index, buildStorage(index));
}
public StorageNested editFirstStorage() {
if (storage.size() == 0) throw new RuntimeException("Can't edit first storage. The list is empty.");
return setNewStorageLike(0, buildStorage(0));
}
public StorageNested editLastStorage() {
int index = storage.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last storage. The list is empty.");
return setNewStorageLike(index, buildStorage(index));
}
public StorageNested editMatchingStorage(Predicate predicate) {
int index = -1;
for (int i=0;i withNewSystemVendor() {
return new SystemVendorNested(null);
}
public SystemVendorNested withNewSystemVendorLike(HardwareSystemVendor item) {
return new SystemVendorNested(item);
}
public SystemVendorNested editSystemVendor() {
return withNewSystemVendorLike(java.util.Optional.ofNullable(buildSystemVendor()).orElse(null));
}
public SystemVendorNested editOrNewSystemVendor() {
return withNewSystemVendorLike(java.util.Optional.ofNullable(buildSystemVendor()).orElse(new HardwareSystemVendorBuilder().build()));
}
public SystemVendorNested editOrNewSystemVendorLike(HardwareSystemVendor item) {
return withNewSystemVendorLike(java.util.Optional.ofNullable(buildSystemVendor()).orElse(item));
}
public A addToAdditionalProperties(String key,Object value) {
if(this.additionalProperties == null && key != null && value != null) { this.additionalProperties = new LinkedHashMap(); }
if(key != null && value != null) {this.additionalProperties.put(key, value);} return (A)this;
}
public A addToAdditionalProperties(Map map) {
if(this.additionalProperties == null && map != null) { this.additionalProperties = new LinkedHashMap(); }
if(map != null) { this.additionalProperties.putAll(map);} return (A)this;
}
public A removeFromAdditionalProperties(String key) {
if(this.additionalProperties == null) { return (A) this; }
if(key != null && this.additionalProperties != null) {this.additionalProperties.remove(key);} return (A)this;
}
public A removeFromAdditionalProperties(Map map) {
if(this.additionalProperties == null) { return (A) this; }
if(map != null) { for(Object key : map.keySet()) {if (this.additionalProperties != null){this.additionalProperties.remove(key);}}} return (A)this;
}
public Map getAdditionalProperties() {
return this.additionalProperties;
}
public A withAdditionalProperties(Map additionalProperties) {
if (additionalProperties == null) {
this.additionalProperties = null;
} else {
this.additionalProperties = new LinkedHashMap(additionalProperties);
}
return (A) this;
}
public boolean hasAdditionalProperties() {
return this.additionalProperties != null;
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
HardwareDetailsFluent that = (HardwareDetailsFluent) o;
if (!java.util.Objects.equals(cpu, that.cpu)) return false;
if (!java.util.Objects.equals(firmware, that.firmware)) return false;
if (!java.util.Objects.equals(hostname, that.hostname)) return false;
if (!java.util.Objects.equals(nics, that.nics)) return false;
if (!java.util.Objects.equals(ramMebibytes, that.ramMebibytes)) return false;
if (!java.util.Objects.equals(storage, that.storage)) return false;
if (!java.util.Objects.equals(systemVendor, that.systemVendor)) return false;
if (!java.util.Objects.equals(additionalProperties, that.additionalProperties)) return false;
return true;
}
public int hashCode() {
return java.util.Objects.hash(cpu, firmware, hostname, nics, ramMebibytes, storage, systemVendor, additionalProperties, super.hashCode());
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (cpu != null) { sb.append("cpu:"); sb.append(cpu + ","); }
if (firmware != null) { sb.append("firmware:"); sb.append(firmware + ","); }
if (hostname != null) { sb.append("hostname:"); sb.append(hostname + ","); }
if (nics != null && !nics.isEmpty()) { sb.append("nics:"); sb.append(nics + ","); }
if (ramMebibytes != null) { sb.append("ramMebibytes:"); sb.append(ramMebibytes + ","); }
if (storage != null && !storage.isEmpty()) { sb.append("storage:"); sb.append(storage + ","); }
if (systemVendor != null) { sb.append("systemVendor:"); sb.append(systemVendor + ","); }
if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
sb.append("}");
return sb.toString();
}
public class CpuNested extends CPUFluent> implements Nested{
CpuNested(CPU item) {
this.builder = new CPUBuilder(this, item);
}
CPUBuilder builder;
public N and() {
return (N) HardwareDetailsFluent.this.withCpu(builder.build());
}
public N endCpu() {
return and();
}
}
public class FirmwareNested extends FirmwareFluent> implements Nested{
FirmwareNested(Firmware item) {
this.builder = new FirmwareBuilder(this, item);
}
FirmwareBuilder builder;
public N and() {
return (N) HardwareDetailsFluent.this.withFirmware(builder.build());
}
public N endFirmware() {
return and();
}
}
public class NicsNested extends NICFluent> implements Nested{
NicsNested(int index,NIC item) {
this.index = index;
this.builder = new NICBuilder(this, item);
}
NICBuilder builder;
int index;
public N and() {
return (N) HardwareDetailsFluent.this.setToNics(index,builder.build());
}
public N endNic() {
return and();
}
}
public class StorageNested extends StorageFluent> implements Nested{
StorageNested(int index,Storage item) {
this.index = index;
this.builder = new StorageBuilder(this, item);
}
StorageBuilder builder;
int index;
public N and() {
return (N) HardwareDetailsFluent.this.setToStorage(index,builder.build());
}
public N endStorage() {
return and();
}
}
public class SystemVendorNested extends HardwareSystemVendorFluent> implements Nested{
SystemVendorNested(HardwareSystemVendor item) {
this.builder = new HardwareSystemVendorBuilder(this, item);
}
HardwareSystemVendorBuilder builder;
public N and() {
return (N) HardwareDetailsFluent.this.withSystemVendor(builder.build());
}
public N endSystemVendor() {
return and();
}
}
}