![JAR search and dependency download from the Maven repository](/logo.png)
annotations.io.fabric8.kubernetes.api.model.VolumeBuilder Maven / Gradle / Ivy
package io.fabric8.kubernetes.api.model;
import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import java.lang.Boolean;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.ValidationException;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import java.util.Set;
import java.lang.Object;
public class VolumeBuilder extends VolumeFluentImpl implements VisitableBuilder{
VolumeFluent> fluent;
Boolean validationEnabled;
public VolumeBuilder(){
this(true);
}
public VolumeBuilder(Boolean validationEnabled){
this(new Volume(), validationEnabled);
}
public VolumeBuilder(VolumeFluent> fluent){
this(fluent, true);
}
public VolumeBuilder(VolumeFluent> fluent,Boolean validationEnabled){
this(fluent, new Volume(), validationEnabled);
}
public VolumeBuilder(VolumeFluent> fluent,Volume instance){
this(fluent, instance, true);
}
public VolumeBuilder(VolumeFluent> fluent,Volume instance,Boolean validationEnabled){
this.fluent = fluent;
fluent.withAwsElasticBlockStore(instance.getAwsElasticBlockStore());
fluent.withAzureFile(instance.getAzureFile());
fluent.withCephfs(instance.getCephfs());
fluent.withCinder(instance.getCinder());
fluent.withConfigMap(instance.getConfigMap());
fluent.withDownwardAPI(instance.getDownwardAPI());
fluent.withEmptyDir(instance.getEmptyDir());
fluent.withFc(instance.getFc());
fluent.withFlexVolume(instance.getFlexVolume());
fluent.withFlocker(instance.getFlocker());
fluent.withGcePersistentDisk(instance.getGcePersistentDisk());
fluent.withGitRepo(instance.getGitRepo());
fluent.withGlusterfs(instance.getGlusterfs());
fluent.withHostPath(instance.getHostPath());
fluent.withIscsi(instance.getIscsi());
fluent.withMetadata(instance.getMetadata());
fluent.withName(instance.getName());
fluent.withNfs(instance.getNfs());
fluent.withPersistentVolumeClaim(instance.getPersistentVolumeClaim());
fluent.withRbd(instance.getRbd());
fluent.withSecret(instance.getSecret());
fluent.withVsphereVolume(instance.getVsphereVolume());
this.validationEnabled = validationEnabled;
}
public VolumeBuilder(Volume instance){
this(instance,true);
}
public VolumeBuilder(Volume instance,Boolean validationEnabled){
this.fluent = this;
this.withAwsElasticBlockStore(instance.getAwsElasticBlockStore());
this.withAzureFile(instance.getAzureFile());
this.withCephfs(instance.getCephfs());
this.withCinder(instance.getCinder());
this.withConfigMap(instance.getConfigMap());
this.withDownwardAPI(instance.getDownwardAPI());
this.withEmptyDir(instance.getEmptyDir());
this.withFc(instance.getFc());
this.withFlexVolume(instance.getFlexVolume());
this.withFlocker(instance.getFlocker());
this.withGcePersistentDisk(instance.getGcePersistentDisk());
this.withGitRepo(instance.getGitRepo());
this.withGlusterfs(instance.getGlusterfs());
this.withHostPath(instance.getHostPath());
this.withIscsi(instance.getIscsi());
this.withMetadata(instance.getMetadata());
this.withName(instance.getName());
this.withNfs(instance.getNfs());
this.withPersistentVolumeClaim(instance.getPersistentVolumeClaim());
this.withRbd(instance.getRbd());
this.withSecret(instance.getSecret());
this.withVsphereVolume(instance.getVsphereVolume());
this.validationEnabled = validationEnabled;
}
public Volume build(){
Volume buildable = new Volume(fluent.getAwsElasticBlockStore(),fluent.getAzureFile(),fluent.getCephfs(),fluent.getCinder(),fluent.getConfigMap(),fluent.getDownwardAPI(),fluent.getEmptyDir(),fluent.getFc(),fluent.getFlexVolume(),fluent.getFlocker(),fluent.getGcePersistentDisk(),fluent.getGitRepo(),fluent.getGlusterfs(),fluent.getHostPath(),fluent.getIscsi(),fluent.getMetadata(),fluent.getName(),fluent.getNfs(),fluent.getPersistentVolumeClaim(),fluent.getRbd(),fluent.getSecret(),fluent.getVsphereVolume());
validate(buildable);
return buildable;
}
private void validate(T item){
if (!validationEnabled) { return; }
Validator validator = null;
try {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
validator = factory.getValidator();
} catch(ValidationException e) {return;}
Set> violations = validator.validate(item);
if (!violations.isEmpty()) {
throw new ConstraintViolationException(violations);
}
}
public boolean equals(Object o){
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
VolumeBuilder that = (VolumeBuilder) o;
if (fluent != null &&fluent != this ? !fluent.equals(that.fluent) :that.fluent != null &&fluent != this ) return false;
if (validationEnabled != null ? !validationEnabled.equals(that.validationEnabled) :that.validationEnabled != null) return false;
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy