package com.hubspot.mesos;

import org.apache.mesos.Protos;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;

import java.util.Collections;
import java.util.List;
import java.util.Map;

public class SingularityDockerInfo {
  private final String image;
  private final boolean privileged;
  private final Optional<SingularityDockerNetworkType> network;
  private final List<SingularityDockerPortMapping> portMappings;
  private final boolean forcePullImage;
  private final Map<String, String> parameters;

  @JsonCreator
  public SingularityDockerInfo(@JsonProperty("image") String image,
                               @JsonProperty("privileged") boolean privileged,
                               @JsonProperty("network") SingularityDockerNetworkType network,
                               @JsonProperty("portMappings") Optional<List<SingularityDockerPortMapping>> portMappings,
                               @JsonProperty("forcePullImage") boolean forcePullImage,
                               @JsonProperty("parameters") Optional<Map<String, String>> parameters) {
    this.image = image;
    this.privileged = privileged;
    this.network = Optional.fromNullable(network);
    this.portMappings = portMappings.or(Collections.<SingularityDockerPortMapping>emptyList());
    this.forcePullImage = forcePullImage;
    this.parameters = parameters.or(Collections.<String, String>emptyMap());
  }

  public String getImage() {
    return image;
  }

  public boolean isPrivileged()
  {
    return privileged;
  }

  public Optional<SingularityDockerNetworkType> getNetwork() {
    return network;
  }

  public List<SingularityDockerPortMapping> getPortMappings() {
    return portMappings;
  }

  public boolean isForcePullImage() {
    return forcePullImage;
  }

  public Map<String, String> getParameters() {
    return parameters;
  }

  @Override
  public String toString() {
    return String.format("DockerInfo [image=%s, network=%s, portMappings=%s, privileged=%s, forcePullImage=%s, parameters=%s]", image, network, portMappings, privileged, forcePullImage, parameters);
  }
}

@@ -32,31 +32,74 @@
 ort 
-org.apache.mesos.Protos
+java.util.Collections;%0Aimport java.util.List;%0Aimport java.util.Map
 ;%0A%0Ai
@@ -249,84 +249,8 @@
 l;%0A%0A
-import java.util.Collections;%0Aimport java.util.List;%0Aimport java.util.Map;%0A%0A
 publ
@@ -1960,198 +1960,1461 @@
 urn 
-String.format(%22DockerInfo %5Bimage=%25s, network=%25s, portMappings=%25s, privileged=%25s, forcePullImage=%25s, parameters=%25s%5D%22, image, network, portMappings, privileged, forcePullImage, parameters)
+%22SingularityDockerInfo%7B%22 +%0A      %22image='%22 + image + '%5C'' +%0A      %22, privileged=%22 + privileged +%0A      %22, network=%22 + network +%0A      %22, portMappings=%22 + portMappings +%0A      %22, forcePullImage=%22 + forcePullImage +%0A      %22, parameters=%22 + parameters +%0A      '%7D';%0A  %7D%0A%0A  @Override%0A  public boolean equals(Object o) %7B%0A    if (this == o) return true;%0A    if (o == null %7C%7C getClass() != o.getClass()) return false;%0A%0A    SingularityDockerInfo that = (SingularityDockerInfo) o;%0A%0A    if (forcePullImage != that.forcePullImage) return false;%0A    if (privileged != that.privileged) return false;%0A    if (image != null ? !image.equals(that.image) : that.image != null) return false;%0A    if (network != null ? !network.equals(that.network) : that.network != null) return false;%0A    if (parameters != null ? !parameters.equals(that.parameters) : that.parameters != null) return false;%0A    if (portMappings != null ? !portMappings.equals(that.portMappings) : that.portMappings != null) return false;%0A%0A    return true;%0A  %7D%0A%0A  @Override%0A  public int hashCode() %7B%0A    int result = image != null ? image.hashCode() : 0;%0A    result = 31 * result + (privileged ? 1 : 0);%0A    result = 31 * result + (network != null ? network.hashCode() : 0);%0A    result = 31 * result + (portMappings != null ? portMappings.hashCode() : 0);%0A    result = 31 * result + (forcePullImage ? 1 : 0);%0A    result = 31 * result + (parameters != null ? parameters.hashCode() : 0);%0A    return result
 ;%0A  %7D%0A
+
 %7D
-%0A

fix SingularityDockerInfo fields