io.fabric8.kubernetes.api.model.PersistentVolumeSpecBuilder Maven / Gradle / Ivy
package io.fabric8.kubernetes.api.model;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.ValidationException;
import java.util.Set;
import java.util.ArrayList;
import java.util.RandomAccess;
import java.util.Map;
import java.util.Map;
import java.util.List;
import java.util.List;
import java.util.AbstractCollection;
import java.util.AbstractList;
import java.util.Map;
import java.util.HashMap;
import java.io.Serializable;
import java.util.Collection;
import java.util.AbstractMap;
import io.fabric8.kubernetes.api.builder.Visitable;
import io.fabric8.kubernetes.api.builder.Builder;
import io.fabric8.kubernetes.api.builder.Fluent;
import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import io.fabric8.kubernetes.api.builder.Visitable;
import io.fabric8.kubernetes.api.builder.BaseFluent;
public class PersistentVolumeSpecBuilder extends PersistentVolumeSpecFluentImpl implements VisitableBuilder{
PersistentVolumeSpecFluent> fluent;
public PersistentVolumeSpecBuilder(){
this(new PersistentVolumeSpec());
}
public PersistentVolumeSpecBuilder( PersistentVolumeSpecFluent> fluent ){
this(fluent, new PersistentVolumeSpec());
}
public PersistentVolumeSpecBuilder( PersistentVolumeSpecFluent> fluent , PersistentVolumeSpec instance ){
this.fluent = fluent; fluent.withAccessModes(instance.getAccessModes()); fluent.withAwsElasticBlockStore(instance.getAwsElasticBlockStore()); fluent.withAzureFile(instance.getAzureFile()); fluent.withCapacity(instance.getCapacity()); fluent.withCephfs(instance.getCephfs()); fluent.withCinder(instance.getCinder()); fluent.withClaimRef(instance.getClaimRef()); fluent.withFc(instance.getFc()); fluent.withFlexVolume(instance.getFlexVolume()); fluent.withFlocker(instance.getFlocker()); fluent.withGcePersistentDisk(instance.getGcePersistentDisk()); fluent.withGlusterfs(instance.getGlusterfs()); fluent.withHostPath(instance.getHostPath()); fluent.withIscsi(instance.getIscsi()); fluent.withNfs(instance.getNfs()); fluent.withPersistentVolumeReclaimPolicy(instance.getPersistentVolumeReclaimPolicy()); fluent.withRbd(instance.getRbd());
}
public PersistentVolumeSpecBuilder( PersistentVolumeSpec instance ){
this.fluent = this; this.withAccessModes(instance.getAccessModes()); this.withAwsElasticBlockStore(instance.getAwsElasticBlockStore()); this.withAzureFile(instance.getAzureFile()); this.withCapacity(instance.getCapacity()); this.withCephfs(instance.getCephfs()); this.withCinder(instance.getCinder()); this.withClaimRef(instance.getClaimRef()); this.withFc(instance.getFc()); this.withFlexVolume(instance.getFlexVolume()); this.withFlocker(instance.getFlocker()); this.withGcePersistentDisk(instance.getGcePersistentDisk()); this.withGlusterfs(instance.getGlusterfs()); this.withHostPath(instance.getHostPath()); this.withIscsi(instance.getIscsi()); this.withNfs(instance.getNfs()); this.withPersistentVolumeReclaimPolicy(instance.getPersistentVolumeReclaimPolicy()); this.withRbd(instance.getRbd());
}
public EditablePersistentVolumeSpec build(){
EditablePersistentVolumeSpec buildable = new EditablePersistentVolumeSpec(fluent.getAccessModes(),fluent.getAwsElasticBlockStore(),fluent.getAzureFile(),fluent.getCapacity(),fluent.getCephfs(),fluent.getCinder(),fluent.getClaimRef(),fluent.getFc(),fluent.getFlexVolume(),fluent.getFlocker(),fluent.getGcePersistentDisk(),fluent.getGlusterfs(),fluent.getHostPath(),fluent.getIscsi(),fluent.getNfs(),fluent.getPersistentVolumeReclaimPolicy(),fluent.getRbd());
validate(buildable);
return buildable;
}
public boolean equals( Object o ){
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
PersistentVolumeSpecBuilder that = (PersistentVolumeSpecBuilder) o;
if (fluent != null &&fluent != this ? !fluent.equals(that.fluent) :that.fluent != null &&fluent != this ) return false;
return true;
}
private void validate(T item) {
try {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
Set> violations = validator.validate(item);
if (!violations.isEmpty()) {
StringBuilder sb = new StringBuilder();
sb.append("Constraint Violations:\n");
for (ConstraintViolation violation : violations) {
sb.append("\t").append(violation.getRootBeanClass().getSimpleName()).append(" ").append(violation.getPropertyPath()).append(":").append(violation.getMessage()).append("\n");
}
throw new IllegalStateException(sb.toString());
}
} catch(ValidationException e) {
//ignore
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy