@Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((connection == null) ? 0 : connection.hashCode());
   return result;
 }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   DockerContainersCategory other = (DockerContainersCategory) obj;
   if (connection == null) {
     if (other.connection != null) return false;
   } else if (!connection.equals(other.connection)) return false;
   return true;
 }
 /**
  * Checks if an image with the given {@code repo} and {@code tag} exists in the given {@code
  * dockerConnection}
  *
  * <p>Workaround until https://bugs.eclipse.org/bugs/show_bug.cgi?id=495243 is fixed.
  *
  * @param dockerConnection the {@link IDockerConnection}
  * @param repoName the repository/name of the image to look-up
  * @param tag the image tag
  * @return <code>true</code> if match found, <code>false</code> otherwise
  */
 public static boolean hasImage(
     final IDockerConnection dockerConnection, final String repoName, final String tag) {
   for (IDockerImage image : dockerConnection.getImages()) {
     final Map<String, List<String>> repoTags = extractTagsByRepo(image.repoTags());
     for (Entry<String, List<String>> entry : repoTags.entrySet()) {
       final String repo = entry.getKey();
       final List<String> tags = entry.getValue();
       if (repo != null && repo.equals(repoName) && tags != null && tags.contains(tag)) {
         return true;
       }
     }
   }
   return false;
 }
  @Override
  public Object[] getChildren(final Object parentElement) {
    if (parentElement instanceof IDockerConnection) {
      final IDockerConnection dockerConnection = (IDockerConnection) parentElement;
      return new Object[] {
        new DockerImagesCategory(dockerConnection), new DockerContainersCategory(dockerConnection)
      };
    } else if (parentElement instanceof DockerContainersCategory) {
      final DockerContainersCategory containersCategory = (DockerContainersCategory) parentElement;
      final IDockerConnection connection = containersCategory.getConnection();
      if (connection.isContainersLoaded()) {
        return connection.getContainers().toArray();
      }
      loadContainers(containersCategory);
      return new Object[] {new LoadingStub(containersCategory)};
    } else if (parentElement instanceof DockerImagesCategory) {
      final DockerImagesCategory imagesCategory = (DockerImagesCategory) parentElement;
      final IDockerConnection connection = imagesCategory.getConnection();
      if (connection.isImagesLoaded()) {
        return connection.getImages().toArray();
      }
      loadImages(imagesCategory);
      return new Object[] {new LoadingStub(imagesCategory)};
    } else if (parentElement instanceof IDockerContainer) {
      final DockerContainer container = (DockerContainer) parentElement;
      if (container.isInfoLoaded()) {
        final IDockerContainerInfo info = container.info();
        final IDockerNetworkSettings networkSettings = info.networkSettings();
        final IDockerHostConfig hostConfig = info.hostConfig();
        return new Object[] {
          new DockerContainerPortMappingsCategory(container, networkSettings.ports()),
          new DockerContainerVolumesCategory(container, hostConfig.binds()),
          new DockerContainerLinksCategory(container, hostConfig.links())
        };
      }
      loadContainerInfo(container);
      return new Object[] {new LoadingStub(container)};
    } else if (parentElement instanceof DockerContainerLinksCategory) {
      final DockerContainerLinksCategory linksCategory =
          (DockerContainerLinksCategory) parentElement;
      return linksCategory.getLinks().toArray();
    } else if (parentElement instanceof DockerContainerPortMappingsCategory) {
      final DockerContainerPortMappingsCategory portMappingsCategory =
          (DockerContainerPortMappingsCategory) parentElement;
      return portMappingsCategory.getPortMappings().toArray();

    } else if (parentElement instanceof DockerContainerVolumesCategory) {
      final DockerContainerVolumesCategory volumesCategory =
          (DockerContainerVolumesCategory) parentElement;
      return volumesCategory.getVolumes().toArray();
    }
    return EMPTY;
  }
 public ImageRunResourceVolumesVariablesModel(final IDockerConnection connection)
     throws DockerException {
   this.connection = connection;
   this.info = connection.getInfo();
 }