All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.spotify.docker.client.messages.Container Maven / Gradle / Ivy

There is a newer version: 8.16.0
Show newest version
/*
 * Copyright (c) 2014 Spotify AB.
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package com.spotify.docker.client.messages;

import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;

@JsonAutoDetect(fieldVisibility = ANY, getterVisibility = NONE, setterVisibility = NONE)
public class Container {

  @JsonProperty("Id") private String id;
  @JsonProperty("Names") private ImmutableList names;
  @JsonProperty("Image") private String image;
  @JsonProperty("Command") private String command;
  @JsonProperty("Created") private Long created;
  @JsonProperty("Status") private String status;
  @JsonProperty("Ports") private ImmutableList ports;
  @JsonProperty("SizeRw") private Long sizeRw;
  @JsonProperty("SizeRootFs") private Long sizeRootFs;

  public String id() {
    return id;
  }

  public List names() {
    return names;
  }

  public String image() {
    return image;
  }

  public String command() {
    return command;
  }

  public Long created() {
    return created;
  }

  public String status() {
    return status;
  }

  public List ports() {
    return ports;
  }

  public Long sizeRw() {
    return sizeRw;
  }

  public Long sizeRootFs() {
    return sizeRootFs;
  }

  @Override
  public boolean equals(final Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }

    final Container container = (Container) o;

    if (command != null ? !command.equals(container.command) : container.command != null) {
      return false;
    }
    if (created != null ? !created.equals(container.created) : container.created != null) {
      return false;
    }
    if (id != null ? !id.equals(container.id) : container.id != null) {
      return false;
    }
    if (image != null ? !image.equals(container.image) : container.image != null) {
      return false;
    }
    if (names != null ? !names.equals(container.names) : container.names != null) {
      return false;
    }
    if (ports != null ? !ports.equals(container.ports) : container.ports != null) {
      return false;
    }
    if (sizeRootFs != null ? !sizeRootFs.equals(container.sizeRootFs)
                           : container.sizeRootFs != null) {
      return false;
    }
    if (sizeRw != null ? !sizeRw.equals(container.sizeRw) : container.sizeRw != null) {
      return false;
    }
    if (status != null ? !status.equals(container.status) : container.status != null) {
      return false;
    }

    return true;
  }

  @Override
  public int hashCode() {
    int result = id != null ? id.hashCode() : 0;
    result = 31 * result + (names != null ? names.hashCode() : 0);
    result = 31 * result + (image != null ? image.hashCode() : 0);
    result = 31 * result + (command != null ? command.hashCode() : 0);
    result = 31 * result + (created != null ? created.hashCode() : 0);
    result = 31 * result + (status != null ? status.hashCode() : 0);
    result = 31 * result + (ports != null ? ports.hashCode() : 0);
    result = 31 * result + (sizeRw != null ? sizeRw.hashCode() : 0);
    result = 31 * result + (sizeRootFs != null ? sizeRootFs.hashCode() : 0);
    return result;
  }

  @Override
  public String toString() {
    return Objects.toStringHelper(this)
        .add("id", id)
        .add("image", image)
        .add("command", command)
        .add("created", created)
        .add("status", status)
        .add("ports", ports)
        .add("sizeRw", sizeRw)
        .add("sizeRootFs", sizeRootFs)
        .toString();
  }

  public static class PortMapping {

    @JsonProperty("PrivatePort") private int privatePort;
    @JsonProperty("PublicPort") private int publicPort;
    @JsonProperty("Type") private String type;
    @JsonProperty("IP") private String ip;

    @Override
    public boolean equals(final Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }

      final PortMapping that = (PortMapping) o;

      if (privatePort != that.privatePort) {
        return false;
      }
      if (publicPort != that.publicPort) {
        return false;
      }
      if (ip != null ? !ip.equals(that.ip) : that.ip != null) {
        return false;
      }
      if (type != null ? !type.equals(that.type) : that.type != null) {
        return false;
      }

      return true;
    }

    @Override
    public int hashCode() {
      int result = privatePort;
      result = 31 * result + publicPort;
      result = 31 * result + (type != null ? type.hashCode() : 0);
      result = 31 * result + (ip != null ? ip.hashCode() : 0);
      return result;
    }

    @Override
    public String toString() {
      return Objects.toStringHelper(this)
          .add("privatePort", privatePort)
          .add("publicPort", publicPort)
          .add("type", type)
          .add("ip", ip)
          .toString();
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy