io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.HardwareDetailsFluentImpl 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 java.lang.Deprecated;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.lang.Boolean;
import java.lang.Integer;
import java.util.Collection;
import java.lang.Object;
import java.util.Map;
/**
* Generated
*/
@SuppressWarnings(value = "unchecked")
public class HardwareDetailsFluentImpl> extends BaseFluent implements HardwareDetailsFluent{
public HardwareDetailsFluentImpl() {
}
public HardwareDetailsFluentImpl(HardwareDetails instance) {
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());
}
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;
/**
* This method has been deprecated, please use method buildCpu instead.
* @return The buildable object.
*/
@Deprecated
public CPU getCpu() {
return this.cpu!=null ?this.cpu.build():null;
}
public CPU buildCpu() {
return this.cpu!=null ?this.cpu.build():null;
}
public A withCpu(CPU cpu) {
_visitables.get("cpu").remove(this.cpu);
if (cpu!=null){ this.cpu= new CPUBuilder(cpu); _visitables.get("cpu").add(this.cpu);} else { this.cpu = null; _visitables.get("cpu").remove(this.cpu); } return (A) this;
}
public Boolean hasCpu() {
return this.cpu != null;
}
public HardwareDetailsFluent.CpuNested withNewCpu() {
return new HardwareDetailsFluentImpl.CpuNestedImpl();
}
public HardwareDetailsFluent.CpuNested withNewCpuLike(CPU item) {
return new HardwareDetailsFluentImpl.CpuNestedImpl(item);
}
public HardwareDetailsFluent.CpuNested editCpu() {
return withNewCpuLike(getCpu());
}
public HardwareDetailsFluent.CpuNested editOrNewCpu() {
return withNewCpuLike(getCpu() != null ? getCpu(): new CPUBuilder().build());
}
public HardwareDetailsFluent.CpuNested editOrNewCpuLike(CPU item) {
return withNewCpuLike(getCpu() != null ? getCpu(): item);
}
/**
* This method has been deprecated, please use method buildFirmware instead.
* @return The buildable object.
*/
@Deprecated
public Firmware getFirmware() {
return this.firmware!=null ?this.firmware.build():null;
}
public Firmware buildFirmware() {
return this.firmware!=null ?this.firmware.build():null;
}
public A withFirmware(Firmware firmware) {
_visitables.get("firmware").remove(this.firmware);
if (firmware!=null){ this.firmware= new FirmwareBuilder(firmware); _visitables.get("firmware").add(this.firmware);} else { this.firmware = null; _visitables.get("firmware").remove(this.firmware); } return (A) this;
}
public Boolean hasFirmware() {
return this.firmware != null;
}
public HardwareDetailsFluent.FirmwareNested withNewFirmware() {
return new HardwareDetailsFluentImpl.FirmwareNestedImpl();
}
public HardwareDetailsFluent.FirmwareNested withNewFirmwareLike(Firmware item) {
return new HardwareDetailsFluentImpl.FirmwareNestedImpl(item);
}
public HardwareDetailsFluent.FirmwareNested editFirmware() {
return withNewFirmwareLike(getFirmware());
}
public HardwareDetailsFluent.FirmwareNested editOrNewFirmware() {
return withNewFirmwareLike(getFirmware() != null ? getFirmware(): new FirmwareBuilder().build());
}
public HardwareDetailsFluent.FirmwareNested editOrNewFirmwareLike(Firmware item) {
return withNewFirmwareLike(getFirmware() != null ? getFirmware(): 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(Integer index,NIC item) {
if (this.nics == null) {this.nics = new ArrayList();}
NICBuilder builder = new NICBuilder(item);_visitables.get("nics").add(index >= 0 ? index : _visitables.get("nics").size(), builder);this.nics.add(index >= 0 ? index : nics.size(), builder); return (A)this;
}
public A setToNics(Integer index,NIC item) {
if (this.nics == null) {this.nics = new ArrayList();}
NICBuilder builder = new NICBuilder(item);
if (index < 0 || index >= _visitables.get("nics").size()) { _visitables.get("nics").add(builder); } else { _visitables.get("nics").set(index, builder);}
if (index < 0 || index >= nics.size()) { nics.add(builder); } else { 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) {
for (NIC item : items) {NICBuilder builder = new NICBuilder(item);_visitables.get("nics").remove(builder);if (this.nics != null) {this.nics.remove(builder);}} return (A)this;
}
public A removeAllFromNics(Collection items) {
for (NIC item : items) {NICBuilder builder = new NICBuilder(item);_visitables.get("nics").remove(builder);if (this.nics != null) {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;
}
/**
* This method has been deprecated, please use method buildNics instead.
* @return The buildable object.
*/
@Deprecated
public List getNics() {
return nics != null ? build(nics) : null;
}
public List buildNics() {
return nics != null ? build(nics) : null;
}
public NIC buildNic(Integer 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) { _visitables.get("nics").removeAll(this.nics);}
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();}
if (nics != null) {for (NIC item :nics){ this.addToNics(item);}} return (A) this;
}
public Boolean hasNics() {
return nics != null && !nics.isEmpty();
}
public HardwareDetailsFluent.NicsNested addNewNic() {
return new HardwareDetailsFluentImpl.NicsNestedImpl();
}
public HardwareDetailsFluent.NicsNested addNewNicLike(NIC item) {
return new HardwareDetailsFluentImpl.NicsNestedImpl(-1, item);
}
public HardwareDetailsFluent.NicsNested setNewNicLike(Integer index,NIC item) {
return new HardwareDetailsFluentImpl.NicsNestedImpl(index, item);
}
public HardwareDetailsFluent.NicsNested editNic(Integer index) {
if (nics.size() <= index) throw new RuntimeException("Can't edit nics. Index exceeds size.");
return setNewNicLike(index, buildNic(index));
}
public HardwareDetailsFluent.NicsNested editFirstNic() {
if (nics.size() == 0) throw new RuntimeException("Can't edit first nics. The list is empty.");
return setNewNicLike(0, buildNic(0));
}
public HardwareDetailsFluent.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 HardwareDetailsFluent.NicsNested editMatchingNic(Predicate predicate) {
int index = -1;
for (int i=0;i();}
StorageBuilder builder = new StorageBuilder(item);_visitables.get("storage").add(index >= 0 ? index : _visitables.get("storage").size(), builder);this.storage.add(index >= 0 ? index : storage.size(), builder); return (A)this;
}
public A setToStorage(Integer index,Storage item) {
if (this.storage == null) {this.storage = new ArrayList();}
StorageBuilder builder = new StorageBuilder(item);
if (index < 0 || index >= _visitables.get("storage").size()) { _visitables.get("storage").add(builder); } else { _visitables.get("storage").set(index, builder);}
if (index < 0 || index >= storage.size()) { storage.add(builder); } else { 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) {
for (Storage item : items) {StorageBuilder builder = new StorageBuilder(item);_visitables.get("storage").remove(builder);if (this.storage != null) {this.storage.remove(builder);}} return (A)this;
}
public A removeAllFromStorage(Collection items) {
for (Storage item : items) {StorageBuilder builder = new StorageBuilder(item);_visitables.get("storage").remove(builder);if (this.storage != null) {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;
}
/**
* This method has been deprecated, please use method buildStorage instead.
* @return The buildable object.
*/
@Deprecated
public List getStorage() {
return storage != null ? build(storage) : null;
}
public List buildStorage() {
return storage != null ? build(storage) : null;
}
public Storage buildStorage(Integer 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) { _visitables.get("storage").removeAll(this.storage);}
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();}
if (storage != null) {for (Storage item :storage){ this.addToStorage(item);}} return (A) this;
}
public Boolean hasStorage() {
return storage != null && !storage.isEmpty();
}
public HardwareDetailsFluent.StorageNested addNewStorage() {
return new HardwareDetailsFluentImpl.StorageNestedImpl();
}
public HardwareDetailsFluent.StorageNested addNewStorageLike(Storage item) {
return new HardwareDetailsFluentImpl.StorageNestedImpl(-1, item);
}
public HardwareDetailsFluent.StorageNested setNewStorageLike(Integer index,Storage item) {
return new HardwareDetailsFluentImpl.StorageNestedImpl(index, item);
}
public HardwareDetailsFluent.StorageNested editStorage(Integer index) {
if (storage.size() <= index) throw new RuntimeException("Can't edit storage. Index exceeds size.");
return setNewStorageLike(index, buildStorage(index));
}
public HardwareDetailsFluent.StorageNested editFirstStorage() {
if (storage.size() == 0) throw new RuntimeException("Can't edit first storage. The list is empty.");
return setNewStorageLike(0, buildStorage(0));
}
public HardwareDetailsFluent.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 HardwareDetailsFluent.StorageNested editMatchingStorage(Predicate predicate) {
int index = -1;
for (int i=0;i withNewSystemVendor() {
return new HardwareDetailsFluentImpl.SystemVendorNestedImpl();
}
public HardwareDetailsFluent.SystemVendorNested withNewSystemVendorLike(HardwareSystemVendor item) {
return new HardwareDetailsFluentImpl.SystemVendorNestedImpl(item);
}
public HardwareDetailsFluent.SystemVendorNested editSystemVendor() {
return withNewSystemVendorLike(getSystemVendor());
}
public HardwareDetailsFluent.SystemVendorNested editOrNewSystemVendor() {
return withNewSystemVendorLike(getSystemVendor() != null ? getSystemVendor(): new HardwareSystemVendorBuilder().build());
}
public HardwareDetailsFluent.SystemVendorNested editOrNewSystemVendorLike(HardwareSystemVendor item) {
return withNewSystemVendorLike(getSystemVendor() != null ? getSystemVendor(): 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;
HardwareDetailsFluentImpl that = (HardwareDetailsFluentImpl) o;
if (cpu != null ? !cpu.equals(that.cpu) :that.cpu != null) return false;
if (firmware != null ? !firmware.equals(that.firmware) :that.firmware != null) return false;
if (hostname != null ? !hostname.equals(that.hostname) :that.hostname != null) return false;
if (nics != null ? !nics.equals(that.nics) :that.nics != null) return false;
if (ramMebibytes != null ? !ramMebibytes.equals(that.ramMebibytes) :that.ramMebibytes != null) return false;
if (storage != null ? !storage.equals(that.storage) :that.storage != null) return false;
if (systemVendor != null ? !systemVendor.equals(that.systemVendor) :that.systemVendor != null) return false;
if (additionalProperties != null ? !additionalProperties.equals(that.additionalProperties) :that.additionalProperties != null) 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();
}
class CpuNestedImpl extends CPUFluentImpl> implements HardwareDetailsFluent.CpuNested,Nested{
CpuNestedImpl(CPU item) {
this.builder = new CPUBuilder(this, item);
}
CpuNestedImpl() {
this.builder = new CPUBuilder(this);
}
CPUBuilder builder;
public N and() {
return (N) HardwareDetailsFluentImpl.this.withCpu(builder.build());
}
public N endCpu() {
return and();
}
}
class FirmwareNestedImpl extends FirmwareFluentImpl> implements HardwareDetailsFluent.FirmwareNested,Nested{
FirmwareNestedImpl(Firmware item) {
this.builder = new FirmwareBuilder(this, item);
}
FirmwareNestedImpl() {
this.builder = new FirmwareBuilder(this);
}
FirmwareBuilder builder;
public N and() {
return (N) HardwareDetailsFluentImpl.this.withFirmware(builder.build());
}
public N endFirmware() {
return and();
}
}
class NicsNestedImpl extends NICFluentImpl> implements HardwareDetailsFluent.NicsNested,Nested{
NicsNestedImpl(Integer index,NIC item) {
this.index = index;
this.builder = new NICBuilder(this, item);
}
NicsNestedImpl() {
this.index = -1;
this.builder = new NICBuilder(this);
}
NICBuilder builder;
Integer index;
public N and() {
return (N) HardwareDetailsFluentImpl.this.setToNics(index,builder.build());
}
public N endNic() {
return and();
}
}
class StorageNestedImpl extends StorageFluentImpl> implements HardwareDetailsFluent.StorageNested,Nested{
StorageNestedImpl(Integer index,Storage item) {
this.index = index;
this.builder = new StorageBuilder(this, item);
}
StorageNestedImpl() {
this.index = -1;
this.builder = new StorageBuilder(this);
}
StorageBuilder builder;
Integer index;
public N and() {
return (N) HardwareDetailsFluentImpl.this.setToStorage(index,builder.build());
}
public N endStorage() {
return and();
}
}
class SystemVendorNestedImpl extends HardwareSystemVendorFluentImpl> implements HardwareDetailsFluent.SystemVendorNested,Nested{
SystemVendorNestedImpl(HardwareSystemVendor item) {
this.builder = new HardwareSystemVendorBuilder(this, item);
}
SystemVendorNestedImpl() {
this.builder = new HardwareSystemVendorBuilder(this);
}
HardwareSystemVendorBuilder builder;
public N and() {
return (N) HardwareDetailsFluentImpl.this.withSystemVendor(builder.build());
}
public N endSystemVendor() {
return and();
}
}
}