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

org.infinispan.cli.resources.ContainerResource Maven / Gradle / Ivy

package org.infinispan.cli.resources;

import java.io.IOException;
import java.util.Arrays;
import java.util.Optional;

import org.infinispan.cli.logging.Messages;

/**
 * @author Tristan Tarrant <[email protected]>
 * @since 10.0
 **/
public class ContainerResource extends AbstractResource {
   ContainerResource(ContainersResource parent, String name) {
      super(parent, name);
   }

   @Override
   public Iterable getChildrenNames() {
      return Arrays.asList(CachesResource.NAME, CountersResource.NAME, ConfigurationsResource.NAME, SchemasResource.NAME, TasksResource.NAME);
   }

   @Override
   public Resource getChild(String name) {
      switch (name) {
         case Resource.PARENT:
            return parent;
         case CachesResource.NAME:
            return new CachesResource(this);
         case CountersResource.NAME:
            return new CountersResource(this);
         case ConfigurationsResource.NAME:
            return new ConfigurationsResource(this);
         case SchemasResource.NAME:
            return new SchemasResource(this);
         case TasksResource.NAME:
            return new TasksResource(this);
         default:
            throw Messages.MSG.noSuchResource(name);
      }
   }

   @Override
   public String describe() throws IOException {
      return getConnection().describeContainer(name);
   }

   public static Optional findContainerName(Resource resource) {
      return resource.optionalFindAncestor(ContainerResource.class).map(AbstractResource::getName);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy