io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.SoftwareRAIDVolumeFluentImpl 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.Integer;
import java.lang.Deprecated;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
import java.util.Map;
/**
* Generated
*/
@SuppressWarnings(value = "unchecked")
public class SoftwareRAIDVolumeFluentImpl> extends BaseFluent implements SoftwareRAIDVolumeFluent{
public SoftwareRAIDVolumeFluentImpl() {
}
public SoftwareRAIDVolumeFluentImpl(SoftwareRAIDVolume instance) {
if (instance != null) {
this.withLevel(instance.getLevel());
this.withPhysicalDisks(instance.getPhysicalDisks());
this.withSizeGibibytes(instance.getSizeGibibytes());
this.withAdditionalProperties(instance.getAdditionalProperties());
}
}
private String level;
private ArrayList physicalDisks = new ArrayList();
private Integer sizeGibibytes;
private Map additionalProperties;
public String getLevel() {
return this.level;
}
public A withLevel(String level) {
this.level=level; return (A) this;
}
public Boolean hasLevel() {
return this.level != null;
}
public A addToPhysicalDisks(int index,RootDeviceHints item) {
if (this.physicalDisks == null) {this.physicalDisks = new ArrayList();}
RootDeviceHintsBuilder builder = new RootDeviceHintsBuilder(item);
if (index < 0 || index >= physicalDisks.size()) { _visitables.get("physicalDisks").add(builder); physicalDisks.add(builder); } else { _visitables.get("physicalDisks").add(index, builder); physicalDisks.add(index, builder);}
return (A)this;
}
public A setToPhysicalDisks(int index,RootDeviceHints item) {
if (this.physicalDisks == null) {this.physicalDisks = new ArrayList();}
RootDeviceHintsBuilder builder = new RootDeviceHintsBuilder(item);
if (index < 0 || index >= physicalDisks.size()) { _visitables.get("physicalDisks").add(builder); physicalDisks.add(builder); } else { _visitables.get("physicalDisks").set(index, builder); physicalDisks.set(index, builder);}
return (A)this;
}
public A addToPhysicalDisks(io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.RootDeviceHints... items) {
if (this.physicalDisks == null) {this.physicalDisks = new ArrayList();}
for (RootDeviceHints item : items) {RootDeviceHintsBuilder builder = new RootDeviceHintsBuilder(item);_visitables.get("physicalDisks").add(builder);this.physicalDisks.add(builder);} return (A)this;
}
public A addAllToPhysicalDisks(Collection items) {
if (this.physicalDisks == null) {this.physicalDisks = new ArrayList();}
for (RootDeviceHints item : items) {RootDeviceHintsBuilder builder = new RootDeviceHintsBuilder(item);_visitables.get("physicalDisks").add(builder);this.physicalDisks.add(builder);} return (A)this;
}
public A removeFromPhysicalDisks(io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.RootDeviceHints... items) {
for (RootDeviceHints item : items) {RootDeviceHintsBuilder builder = new RootDeviceHintsBuilder(item);_visitables.get("physicalDisks").remove(builder);if (this.physicalDisks != null) {this.physicalDisks.remove(builder);}} return (A)this;
}
public A removeAllFromPhysicalDisks(Collection items) {
for (RootDeviceHints item : items) {RootDeviceHintsBuilder builder = new RootDeviceHintsBuilder(item);_visitables.get("physicalDisks").remove(builder);if (this.physicalDisks != null) {this.physicalDisks.remove(builder);}} return (A)this;
}
public A removeMatchingFromPhysicalDisks(Predicate predicate) {
if (physicalDisks == null) return (A) this;
final Iterator each = physicalDisks.iterator();
final List visitables = _visitables.get("physicalDisks");
while (each.hasNext()) {
RootDeviceHintsBuilder builder = each.next();
if (predicate.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
/**
* This method has been deprecated, please use method buildPhysicalDisks instead.
* @return The buildable object.
*/
@Deprecated
public List getPhysicalDisks() {
return physicalDisks != null ? build(physicalDisks) : null;
}
public List buildPhysicalDisks() {
return physicalDisks != null ? build(physicalDisks) : null;
}
public RootDeviceHints buildPhysicalDisk(int index) {
return this.physicalDisks.get(index).build();
}
public RootDeviceHints buildFirstPhysicalDisk() {
return this.physicalDisks.get(0).build();
}
public RootDeviceHints buildLastPhysicalDisk() {
return this.physicalDisks.get(physicalDisks.size() - 1).build();
}
public RootDeviceHints buildMatchingPhysicalDisk(Predicate predicate) {
for (RootDeviceHintsBuilder item: physicalDisks) { if(predicate.test(item)){ return item.build();} } return null;
}
public Boolean hasMatchingPhysicalDisk(Predicate predicate) {
for (RootDeviceHintsBuilder item: physicalDisks) { if(predicate.test(item)){ return true;} } return false;
}
public A withPhysicalDisks(List physicalDisks) {
if (this.physicalDisks != null) { _visitables.get("physicalDisks").clear();}
if (physicalDisks != null) {this.physicalDisks = new ArrayList(); for (RootDeviceHints item : physicalDisks){this.addToPhysicalDisks(item);}} else { this.physicalDisks = null;} return (A) this;
}
public A withPhysicalDisks(io.fabric8.openshift.api.model.miscellaneous.metal3.v1alpha1.RootDeviceHints... physicalDisks) {
if (this.physicalDisks != null) {this.physicalDisks.clear(); _visitables.remove("physicalDisks"); }
if (physicalDisks != null) {for (RootDeviceHints item :physicalDisks){ this.addToPhysicalDisks(item);}} return (A) this;
}
public Boolean hasPhysicalDisks() {
return physicalDisks != null && !physicalDisks.isEmpty();
}
public SoftwareRAIDVolumeFluentImpl.PhysicalDisksNested addNewPhysicalDisk() {
return new SoftwareRAIDVolumeFluentImpl.PhysicalDisksNestedImpl();
}
public SoftwareRAIDVolumeFluentImpl.PhysicalDisksNested addNewPhysicalDiskLike(RootDeviceHints item) {
return new SoftwareRAIDVolumeFluentImpl.PhysicalDisksNestedImpl(-1, item);
}
public SoftwareRAIDVolumeFluentImpl.PhysicalDisksNested setNewPhysicalDiskLike(int index,RootDeviceHints item) {
return new SoftwareRAIDVolumeFluentImpl.PhysicalDisksNestedImpl(index, item);
}
public SoftwareRAIDVolumeFluentImpl.PhysicalDisksNested editPhysicalDisk(int index) {
if (physicalDisks.size() <= index) throw new RuntimeException("Can't edit physicalDisks. Index exceeds size.");
return setNewPhysicalDiskLike(index, buildPhysicalDisk(index));
}
public SoftwareRAIDVolumeFluentImpl.PhysicalDisksNested editFirstPhysicalDisk() {
if (physicalDisks.size() == 0) throw new RuntimeException("Can't edit first physicalDisks. The list is empty.");
return setNewPhysicalDiskLike(0, buildPhysicalDisk(0));
}
public SoftwareRAIDVolumeFluentImpl.PhysicalDisksNested editLastPhysicalDisk() {
int index = physicalDisks.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last physicalDisks. The list is empty.");
return setNewPhysicalDiskLike(index, buildPhysicalDisk(index));
}
public SoftwareRAIDVolumeFluentImpl.PhysicalDisksNested editMatchingPhysicalDisk(Predicate predicate) {
int index = -1;
for (int i=0;i 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;
SoftwareRAIDVolumeFluentImpl that = (SoftwareRAIDVolumeFluentImpl) o;
if (!java.util.Objects.equals(level, that.level)) return false;
if (!java.util.Objects.equals(physicalDisks, that.physicalDisks)) return false;
if (!java.util.Objects.equals(sizeGibibytes, that.sizeGibibytes)) return false;
if (!java.util.Objects.equals(additionalProperties, that.additionalProperties)) return false;
return true;
}
public int hashCode() {
return java.util.Objects.hash(level, physicalDisks, sizeGibibytes, additionalProperties, super.hashCode());
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (level != null) { sb.append("level:"); sb.append(level + ","); }
if (physicalDisks != null) { sb.append("physicalDisks:"); sb.append(physicalDisks + ","); }
if (sizeGibibytes != null) { sb.append("sizeGibibytes:"); sb.append(sizeGibibytes + ","); }
if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
sb.append("}");
return sb.toString();
}
class PhysicalDisksNestedImpl extends RootDeviceHintsFluentImpl> implements SoftwareRAIDVolumeFluentImpl.PhysicalDisksNested,Nested{
PhysicalDisksNestedImpl(int index,RootDeviceHints item) {
this.index = index;
this.builder = new RootDeviceHintsBuilder(this, item);
}
PhysicalDisksNestedImpl() {
this.index = -1;
this.builder = new RootDeviceHintsBuilder(this);
}
RootDeviceHintsBuilder builder;
int index;
public N and() {
return (N) SoftwareRAIDVolumeFluentImpl.this.setToPhysicalDisks(index,builder.build());
}
public N endPhysicalDisk() {
return and();
}
}
}