/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (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.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.venice.core;

import java.util.*;

public final class CommunityHideMode implements Comparable
{
  /*--------------------------------------------------------------------------------
   * Static data members
   *--------------------------------------------------------------------------------
   */

  private static ArrayList s_order_list = null;
  private static HashMap s_name_to_enum = null;

  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private String m_name;
  private String m_to_string;

  /*--------------------------------------------------------------------------------
   * Constructor
   *--------------------------------------------------------------------------------
   */

  private CommunityHideMode(String name)
  {
    m_name = name;
    if (s_order_list==null)
      s_order_list = new ArrayList();
    s_order_list.add(this);
    if (s_name_to_enum==null)
      s_name_to_enum = new HashMap();
    s_name_to_enum.put(name,this);
    m_to_string = "CommunityHideMode[" + name + "]";

  } // end constructor

  /*--------------------------------------------------------------------------------
   * Overrides from class Object
   *--------------------------------------------------------------------------------
   */

  public String toString()
  {
    return m_to_string;

  } // end toString

  public int hashCode()
  {
    return m_name.hashCode();

  } // end hashCode

  public boolean equals(Object other)
  {
    if (other==null)
      return false;
    if (other==this)
      return true;
    if (!(other instanceof CommunityHideMode))
      return false;
    return m_name.equals(((CommunityHideMode)other).m_name);

  } // end equals

  /*--------------------------------------------------------------------------------
   * Implementations from class Comparable
   *--------------------------------------------------------------------------------
   */

  public int compareTo(Object other)
  {
    if (other==null)
      throw new NullPointerException();
    if (!(other instanceof CommunityHideMode))
      throw new ClassCastException();
    return m_name.compareTo(((CommunityHideMode)other).m_name);

  } // end compareTo

  /*--------------------------------------------------------------------------------
   * External operations
   *--------------------------------------------------------------------------------
   */

  public Class getEnumClass()
  {
    return CommunityHideMode.class;

  } // end getEnumClass

  public String getName()
  {
    return m_name;

  } // end getName

  /*--------------------------------------------------------------------------------
   * External static operations
   *--------------------------------------------------------------------------------
   */

  public static CommunityHideMode getEnum(String name)
  {
    if (s_name_to_enum==null)
      return null;
    return (CommunityHideMode)(s_name_to_enum.get(name));

  } // end getEnum

  public static Map getEnumMap()
  {
    if (s_name_to_enum==null)
      return Collections.EMPTY_MAP;
    else
      return Collections.unmodifiableMap(s_name_to_enum);

  } // end getEnumMap

  public static List getEnumList()
  {
    if (s_order_list==null)
      return Collections.EMPTY_LIST;
    else
      return Collections.unmodifiableList(s_order_list);

  } // end getEnumList

  public static Iterator iterator()
  {
    return getEnumList().iterator();

  } // end iterator

  /*--------------------------------------------------------------------------------
   * Enumerated type values
   *--------------------------------------------------------------------------------
   */

  public static final CommunityHideMode NONE      = new CommunityHideMode("NONE");
  public static final CommunityHideMode DIRECTORY = new CommunityHideMode("DIRECTORY");
  public static final CommunityHideMode BOTH      = new CommunityHideMode("BOTH");

} // end class CommunityHideMode
