
annotations.io.fabric8.docker.api.model.ContainerInspectBuilder Maven / Gradle / Ivy
package io.fabric8.docker.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.List;
import java.util.AbstractCollection;
import java.util.AbstractList;
import java.util.HashMap;
import java.io.Serializable;
import java.util.Collection;
import java.util.AbstractMap;
import io.fabric8.docker.api.builder.Visitable;
import io.fabric8.docker.api.builder.Builder;
import io.fabric8.docker.api.builder.Visitable;
import io.fabric8.docker.api.builder.BaseFluent;
import io.fabric8.docker.api.builder.VisitableBuilder;
import io.fabric8.docker.api.builder.Fluent;
public class ContainerInspectBuilder extends ContainerInspectFluentImpl implements VisitableBuilder{
ContainerInspectFluent> fluent;
public ContainerInspectBuilder(){
this(new ContainerInspect());
}
public ContainerInspectBuilder( ContainerInspectFluent> fluent ){
this(fluent, new ContainerInspect());
}
public ContainerInspectBuilder( ContainerInspectFluent> fluent , ContainerInspect instance ){
this.fluent = fluent; fluent.withAppArmorProfile(instance.getAppArmorProfile()); fluent.withArgs(instance.getArgs()); fluent.withCreated(instance.getCreated()); fluent.withDriver(instance.getDriver()); fluent.withExecDriver(instance.getExecDriver()); fluent.withExecIDs(instance.getExecIDs()); fluent.withGraphDriver(instance.getGraphDriver()); fluent.withHostConfig(instance.getHostConfig()); fluent.withHostnamePath(instance.getHostnamePath()); fluent.withHostsPath(instance.getHostsPath()); fluent.withId(instance.getId()); fluent.withImage(instance.getImage()); fluent.withLogPath(instance.getLogPath()); fluent.withMountLabel(instance.getMountLabel()); fluent.withName(instance.getName()); fluent.withPath(instance.getPath()); fluent.withProcessLabel(instance.getProcessLabel()); fluent.withResolvConfPath(instance.getResolvConfPath()); fluent.withRestartCount(instance.getRestartCount()); fluent.withSizeRootFs(instance.getSizeRootFs()); fluent.withSizeRw(instance.getSizeRw()); fluent.withState(instance.getState()); fluent.withConfig(instance.getConfig()); fluent.withMounts(instance.getMounts()); fluent.withNetworkSettings(instance.getNetworkSettings());
}
public ContainerInspectBuilder( ContainerInspect instance ){
this.fluent = this; this.withAppArmorProfile(instance.getAppArmorProfile()); this.withArgs(instance.getArgs()); this.withCreated(instance.getCreated()); this.withDriver(instance.getDriver()); this.withExecDriver(instance.getExecDriver()); this.withExecIDs(instance.getExecIDs()); this.withGraphDriver(instance.getGraphDriver()); this.withHostConfig(instance.getHostConfig()); this.withHostnamePath(instance.getHostnamePath()); this.withHostsPath(instance.getHostsPath()); this.withId(instance.getId()); this.withImage(instance.getImage()); this.withLogPath(instance.getLogPath()); this.withMountLabel(instance.getMountLabel()); this.withName(instance.getName()); this.withPath(instance.getPath()); this.withProcessLabel(instance.getProcessLabel()); this.withResolvConfPath(instance.getResolvConfPath()); this.withRestartCount(instance.getRestartCount()); this.withSizeRootFs(instance.getSizeRootFs()); this.withSizeRw(instance.getSizeRw()); this.withState(instance.getState()); this.withConfig(instance.getConfig()); this.withMounts(instance.getMounts()); this.withNetworkSettings(instance.getNetworkSettings());
}
public EditableContainerInspect build(){
EditableContainerInspect buildable = new EditableContainerInspect(fluent.getAppArmorProfile(),fluent.getArgs(),fluent.getCreated(),fluent.getDriver(),fluent.getExecDriver(),fluent.getExecIDs(),fluent.getGraphDriver(),fluent.getHostConfig(),fluent.getHostnamePath(),fluent.getHostsPath(),fluent.getId(),fluent.getImage(),fluent.getLogPath(),fluent.getMountLabel(),fluent.getName(),fluent.getPath(),fluent.getProcessLabel(),fluent.getResolvConfPath(),fluent.getRestartCount(),fluent.getSizeRootFs(),fluent.getSizeRw(),fluent.getState(),fluent.getConfig(),fluent.getMounts(),fluent.getNetworkSettings());
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;
ContainerInspectBuilder that = (ContainerInspectBuilder) 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