// Path: src/main/java/com/cloudera/director/spi/v2/model/InstanceState.java
// public interface InstanceState {
// 
//   /**
//    * Returns the instance status.
//    *
//    * @return the instance status
//    */
//   InstanceStatus getInstanceStatus();
// 
//   /**
//    * Returns a localized human-readable version of the instance state.
//    *
//    * @param localizationContext the localization context
//    * @return a localized human-readable version of the instance state
//    */
//   String getInstanceStateDescription(LocalizationContext localizationContext);
// 
//   /**
//    * <p>Returns the provider specific version of this state object or null.</p>
//    * <p>Intended for internal provider use only. The consumer of the API will not try
//    * to use this in any way.</p>
//    */
//   Object unwrap();
// 
// }
// 
// Path: src/main/java/com/cloudera/director/spi/v2/model/InstanceStatus.java
// public enum InstanceStatus {
// 
//   /**
//    * The instance has been requested (initially or after being stopped), but is not yet known to be available.
//    */
//   PENDING,
// 
//   /**
//    * The instance is running, although it may not be accessible.
//    */
//   RUNNING,
// 
//   /**
//    * The instance is stopping, and may be restarted later.
//    */
//   STOPPING,
// 
//   /**
//    * The instance is stopped, and may be restarted.
//    */
//   STOPPED,
// 
//   /**
//    * The instance is being removed permanently.
//    */
//   DELETING,
// 
//   /**
//    * The instance has been removed permanently.
//    */
//   DELETED,
// 
//   /**
//    * The instance has failed, and cannot be reused.
//    */
//   FAILED,
// 
//   /**
//    * The instance state cannot be determined.
//    */
//   UNKNOWN
// }
// 
// Path: src/main/java/com/cloudera/director/spi/v2/model/LocalizationContext.java
// public interface LocalizationContext {
// 
//   /**
//    * Localization context factory.
//    */
//   interface Factory {
// 
//     /**
//      * Creates a root localization context for the specified locale.
//      *
//      * @param locale the locale
//      * @return a root localization context for the specified locale
//      */
//     LocalizationContext createRootLocalizationContext(Locale locale);
//   }
// 
//   /**
//    * Returns the locale.
//    *
//    * @return the locale
//    */
//   Locale getLocale();
// 
//   /**
//    * Returns the key prefix of the context, which can be used for property namespacing.
//    *
//    * @return the key prefix of the context
//    */
//   String getKeyPrefix();
// 
//   /**
//    * Returns a localized value for the specified localization key suffix components,
//    * or the specified default value if a localized value cannot be determined.
//    *
//    * @param defaultValue  the default value to return if a localized value cannot be determined
//    * @param keyComponents the localization key suffix components
//    * @return a localized value for the specified localization key suffix components,
//    * or the specified default value if a localized value cannot be determined
//    */
//   String localize(String defaultValue, String... keyComponents);
// }


import com.cloudera.director.spi.v2.model.InstanceState;
import com.cloudera.director.spi.v2.model.InstanceStatus;
import com.cloudera.director.spi.v2.model.LocalizationContext;
// (c) Copyright 2015 Cloudera, Inc.
//
// Licensed 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.cloudera.director.spi.v2.model.util;


/**
 * Abstract base class for instance state implementations.
 */
public class AbstractInstanceState<T> implements InstanceState {

  /**
   * The instance status.
   */
  private final InstanceStatus instanceStatus;

  /**
   * The provider-specific instance state details.
   */
  private final T instanceStateDetails;

  /**
   * Creates an abstract instance state with the specified parameters.
   *
   * @param instanceStatus       the instance status
   * @param instanceStateDetails the provider-specific instance state details
   */
  public AbstractInstanceState(InstanceStatus instanceStatus, T instanceStateDetails) {
    if (instanceStatus == null) {
      throw new NullPointerException("instanceStatus is null");
    }
    this.instanceStatus = instanceStatus;
    this.instanceStateDetails = instanceStateDetails;
  }

  @Override
  public InstanceStatus getInstanceStatus() {
    return instanceStatus;
  }

  @Override
  public T unwrap() {
    return instanceStateDetails;
  }

  @Override
  // NOTE: This implementation does not do any actual localization, and simply calls toString()
  // on the instance state details. Plugin implementors may override to perform localization.
// Path: src/main/java/com/cloudera/director/spi/v2/model/InstanceState.java
// public interface InstanceState {
// 
//   /**
//    * Returns the instance status.
//    *
//    * @return the instance status
//    */
//   InstanceStatus getInstanceStatus();
// 
//   /**
//    * Returns a localized human-readable version of the instance state.
//    *
//    * @param localizationContext the localization context
//    * @return a localized human-readable version of the instance state
//    */
//   String getInstanceStateDescription(LocalizationContext localizationContext);
// 
//   /**
//    * <p>Returns the provider specific version of this state object or null.</p>
//    * <p>Intended for internal provider use only. The consumer of the API will not try
//    * to use this in any way.</p>
//    */
//   Object unwrap();
// 
// }
// 
// Path: src/main/java/com/cloudera/director/spi/v2/model/InstanceStatus.java
// public enum InstanceStatus {
// 
//   /**
//    * The instance has been requested (initially or after being stopped), but is not yet known to be available.
//    */
//   PENDING,
// 
//   /**
//    * The instance is running, although it may not be accessible.
//    */
//   RUNNING,
// 
//   /**
//    * The instance is stopping, and may be restarted later.
//    */
//   STOPPING,
// 
//   /**
//    * The instance is stopped, and may be restarted.
//    */
//   STOPPED,
// 
//   /**
//    * The instance is being removed permanently.
//    */
//   DELETING,
// 
//   /**
//    * The instance has been removed permanently.
//    */
//   DELETED,
// 
//   /**
//    * The instance has failed, and cannot be reused.
//    */
//   FAILED,
// 
//   /**
//    * The instance state cannot be determined.
//    */
//   UNKNOWN
// }
// 
// Path: src/main/java/com/cloudera/director/spi/v2/model/LocalizationContext.java
// public interface LocalizationContext {
// 
//   /**
//    * Localization context factory.
//    */
//   interface Factory {
// 
//     /**
//      * Creates a root localization context for the specified locale.
//      *
//      * @param locale the locale
//      * @return a root localization context for the specified locale
//      */
//     LocalizationContext createRootLocalizationContext(Locale locale);
//   }
// 
//   /**
//    * Returns the locale.
//    *
//    * @return the locale
//    */
//   Locale getLocale();
// 
//   /**
//    * Returns the key prefix of the context, which can be used for property namespacing.
//    *
//    * @return the key prefix of the context
//    */
//   String getKeyPrefix();
// 
//   /**
//    * Returns a localized value for the specified localization key suffix components,
//    * or the specified default value if a localized value cannot be determined.
//    *
//    * @param defaultValue  the default value to return if a localized value cannot be determined
//    * @param keyComponents the localization key suffix components
//    * @return a localized value for the specified localization key suffix components,
//    * or the specified default value if a localized value cannot be determined
//    */
//   String localize(String defaultValue, String... keyComponents);
// }


// Path: src/main/java/com/cloudera/director/spi/v2/model/util/AbstractInstanceState.java
import com.cloudera.director.spi.v2.model.InstanceState;
import com.cloudera.director.spi.v2.model.InstanceStatus;
import com.cloudera.director.spi.v2.model.LocalizationContext;

// (c) Copyright 2015 Cloudera, Inc.
//
// Licensed 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.cloudera.director.spi.v2.model.util;


/**
 * Abstract base class for instance state implementations.
 */
public class AbstractInstanceState<T> implements InstanceState {

  /**
   * The instance status.
   */
  private final InstanceStatus instanceStatus;

  /**
   * The provider-specific instance state details.
   */
  private final T instanceStateDetails;

  /**
   * Creates an abstract instance state with the specified parameters.
   *
   * @param instanceStatus       the instance status
   * @param instanceStateDetails the provider-specific instance state details
   */
  public AbstractInstanceState(InstanceStatus instanceStatus, T instanceStateDetails) {
    if (instanceStatus == null) {
      throw new NullPointerException("instanceStatus is null");
    }
    this.instanceStatus = instanceStatus;
    this.instanceStateDetails = instanceStateDetails;
  }

  @Override
  public InstanceStatus getInstanceStatus() {
    return instanceStatus;
  }

  @Override
  public T unwrap() {
    return instanceStateDetails;
  }

  @Override
  // NOTE: This implementation does not do any actual localization, and simply calls toString()
  // on the instance state details. Plugin implementors may override to perform localization.
  public String getInstanceStateDescription(LocalizationContext localizationContext) {