//# 0 errors, 119 messages
//#
/*
    //#state.java:1:1: class: net.sourceforge.pebble.domain.State
 * Copyright (c) 2003-2006, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package net.sourceforge.pebble.domain;

import java.io.Serializable;

/**
 * Represents a state.
 *
 * @author    Simon Brown
 */
public class State implements Serializable {

  public static final State APPROVED = new State("approved");
    //#state.java:43: method: net.sourceforge.pebble.domain.State.net.sourceforge.pebble.domain.State__static_init
    //#output(net.sourceforge.pebble.domain.State__static_init): APPROVED
    //#output(net.sourceforge.pebble.domain.State__static_init): PENDING
    //#output(net.sourceforge.pebble.domain.State__static_init): PUBLISHED
    //#output(net.sourceforge.pebble.domain.State__static_init): REJECTED
    //#output(net.sourceforge.pebble.domain.State__static_init): UNPUBLISHED
    //#output(net.sourceforge.pebble.domain.State__static_init): __Descendant_Table[net/sourceforge/pebble/domain/State]
    //#output(net.sourceforge.pebble.domain.State__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z
    //#output(net.sourceforge.pebble.domain.State__static_init): __Dispatch_Table.getName()Ljava/lang/String;
    //#output(net.sourceforge.pebble.domain.State__static_init): __Dispatch_Table.hashCode()I
    //#output(net.sourceforge.pebble.domain.State__static_init): __Dispatch_Table.toString()Ljava/lang/String;
    //#output(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#1) num objects
    //#output(net.sourceforge.pebble.domain.State__static_init): APPROVED.__Tag
    //#output(net.sourceforge.pebble.domain.State__static_init): APPROVED.name
    //#output(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#2) num objects
    //#output(net.sourceforge.pebble.domain.State__static_init): REJECTED.__Tag
    //#output(net.sourceforge.pebble.domain.State__static_init): REJECTED.name
    //#output(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#3) num objects
    //#output(net.sourceforge.pebble.domain.State__static_init): PENDING.__Tag
    //#output(net.sourceforge.pebble.domain.State__static_init): PENDING.name
    //#output(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#4) num objects
    //#output(net.sourceforge.pebble.domain.State__static_init): UNPUBLISHED.__Tag
    //#output(net.sourceforge.pebble.domain.State__static_init): UNPUBLISHED.name
    //#output(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#5) num objects
    //#output(net.sourceforge.pebble.domain.State__static_init): PUBLISHED.__Tag
    //#output(net.sourceforge.pebble.domain.State__static_init): PUBLISHED.name
    //#new obj(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#1)
    //#new obj(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#2)
    //#new obj(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#3)
    //#new obj(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#4)
    //#new obj(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#5)
    //#post(net.sourceforge.pebble.domain.State__static_init): APPROVED == &new State(State__static_init#1)
    //#post(net.sourceforge.pebble.domain.State__static_init): PENDING == &new State(State__static_init#3)
    //#post(net.sourceforge.pebble.domain.State__static_init): PUBLISHED == &new State(State__static_init#5)
    //#post(net.sourceforge.pebble.domain.State__static_init): REJECTED == &new State(State__static_init#2)
    //#post(net.sourceforge.pebble.domain.State__static_init): UNPUBLISHED == &new State(State__static_init#4)
    //#post(net.sourceforge.pebble.domain.State__static_init): __Descendant_Table[net/sourceforge/pebble/domain/State] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.domain.State__static_init): __Dispatch_Table.equals(Ljava/lang/Object;)Z == &equals
    //#post(net.sourceforge.pebble.domain.State__static_init): __Dispatch_Table.getName()Ljava/lang/String; == &getName
    //#post(net.sourceforge.pebble.domain.State__static_init): __Dispatch_Table.hashCode()I == &hashCode
    //#post(net.sourceforge.pebble.domain.State__static_init): __Dispatch_Table.toString()Ljava/lang/String; == &toString
    //#post(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#1) num objects == 1
    //#post(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#2) num objects == 1
    //#post(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#3) num objects == 1
    //#post(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#4) num objects == 1
    //#post(net.sourceforge.pebble.domain.State__static_init): new State(State__static_init#5) num objects == 1
    //#post(net.sourceforge.pebble.domain.State__static_init): APPROVED.__Tag == net/sourceforge/pebble/domain/State
    //#post(net.sourceforge.pebble.domain.State__static_init): REJECTED.__Tag == net/sourceforge/pebble/domain/State
    //#post(net.sourceforge.pebble.domain.State__static_init): PENDING.__Tag == net/sourceforge/pebble/domain/State
    //#post(net.sourceforge.pebble.domain.State__static_init): UNPUBLISHED.__Tag == net/sourceforge/pebble/domain/State
    //#post(net.sourceforge.pebble.domain.State__static_init): PUBLISHED.__Tag == net/sourceforge/pebble/domain/State
    //#post(net.sourceforge.pebble.domain.State__static_init): APPROVED.name == &"approved"
    //#post(net.sourceforge.pebble.domain.State__static_init): REJECTED.name == &"rejected"
    //#post(net.sourceforge.pebble.domain.State__static_init): PENDING.name == &"pending"
    //#post(net.sourceforge.pebble.domain.State__static_init): UNPUBLISHED.name == &"unpublished"
    //#post(net.sourceforge.pebble.domain.State__static_init): PUBLISHED.name == &"published"
  public static final State REJECTED = new State("rejected");
  public static final State PENDING = new State("pending");

  public static final State UNPUBLISHED = new State("unpublished");
  public static final State PUBLISHED = new State("published");
    //#state.java:48: end of method: net.sourceforge.pebble.domain.State.net.sourceforge.pebble.domain.State__static_init

  public static State getState(String name) {
    if (name == null) {
    //#state.java:51: method: State net.sourceforge.pebble.domain.State.getState(String)
    //#input(State getState(String)): APPROVED
    //#input(State getState(String)): PENDING
    //#input(State getState(String)): PUBLISHED
    //#input(State getState(String)): REJECTED
    //#input(State getState(String)): UNPUBLISHED
    //#input(State getState(String)): name
    //#output(State getState(String)): return_value
    //#post(State getState(String)): return_value in Addr_Set{null,&new State(State__static_init#1),&new State(State__static_init#2),&new State(State__static_init#3),&new State(State__static_init#4),&new State(State__static_init#5)}
    //#test_vector(State getState(String)): name: Inverse{null}, Addr_Set{null}
    //#test_vector(State getState(String)): java.lang.String:equals(...)@53: {0}, {1}
    //#test_vector(State getState(String)): java.lang.String:equals(...)@55: {0}, {1}
    //#test_vector(State getState(String)): java.lang.String:equals(...)@57: {0}, {1}
    //#test_vector(State getState(String)): java.lang.String:equals(...)@59: {0}, {1}
    //#test_vector(State getState(String)): java.lang.String:equals(...)@61: {0}, {1}
      return null;
    } else if (name.equals("approved")) {
      return APPROVED;
    } else if (name.equals("rejected")) {
      return REJECTED;
    } else if (name.equals("pending")) {
      return PENDING;
    } else if (name.equals("unpublished")) {
      return UNPUBLISHED;
    } else if (name.equals("published")) {
      return PUBLISHED;
    } else {
      return null;
    //#state.java:64: end of method: State net.sourceforge.pebble.domain.State.getState(String)
    }
  }

  /** the name of the state */
  private String name;

  /**
   * Creates a new instance.
   *
   * @param name    the name of the state
   */
  private State(String name) {
    //#state.java:76: method: void net.sourceforge.pebble.domain.State.net.sourceforge.pebble.domain.State(String)
    //#input(void net.sourceforge.pebble.domain.State(String)): name
    //#input(void net.sourceforge.pebble.domain.State(String)): this
    //#output(void net.sourceforge.pebble.domain.State(String)): this.name
    //#post(void net.sourceforge.pebble.domain.State(String)): this.name == name
    //#post(void net.sourceforge.pebble.domain.State(String)): init'ed(this.name)
    this.name = name;
  }
    //#state.java:78: end of method: void net.sourceforge.pebble.domain.State.net.sourceforge.pebble.domain.State(String)

  /**
   * Gets the name of this state.
   *
   * @return    the name as a String
   */
  public String getName() {
    return name;
    //#state.java:86: method: String net.sourceforge.pebble.domain.State.getName()
    //#input(String getName()): this
    //#input(String getName()): this.name
    //#output(String getName()): return_value
    //#pre[2] (String getName()): init'ed(this.name)
    //#post(String getName()): return_value == this.name
    //#post(String getName()): init'ed(return_value)
    //#state.java:86: end of method: String net.sourceforge.pebble.domain.State.getName()
  }

  /**
   * Gets the hashcode of this object.
   *
   * @return  the hashcode as an int
   */
  public int hashCode() {
    return name.hashCode();
    //#state.java:95: method: int net.sourceforge.pebble.domain.State.hashCode()
    //#input(int hashCode()): this
    //#input(int hashCode()): this.name
    //#output(int hashCode()): return_value
    //#pre[2] (int hashCode()): this.name != null
    //#post(int hashCode()): init'ed(return_value)
    //#state.java:95: end of method: int net.sourceforge.pebble.domain.State.hashCode()
  }

  /**
   * Determines whether the specified object is equal to this one.
   *
   * @param o   the object to compare against
   * @return    true if Object o represents the same category, false otherwise
   */
  public boolean equals(Object o) {
    if (!(o instanceof State)) {
    //#state.java:105: method: bool net.sourceforge.pebble.domain.State.equals(Object)
    //#input(bool equals(Object)): __Descendant_Table[net/sourceforge/pebble/domain/State]
    //#input(bool equals(Object)): __Descendant_Table[others]
    //#input(bool equals(Object)): __Dispatch_Table.getName()Ljava/lang/String;
    //#input(bool equals(Object)): o
    //#input(bool equals(Object)): o.__Tag
    //#input(bool equals(Object)): o.name
    //#input(bool equals(Object)): this
    //#input(bool equals(Object)): this.name
    //#output(bool equals(Object)): return_value
    //#pre[3] (bool equals(Object)): (soft) o.name != null
    //#pre[5] (bool equals(Object)): (soft) init'ed(this.name)
    //#post(bool equals(Object)): init'ed(return_value)
      return false;
    }

    State state = (State)o;
    return state.getName().equals(name);
    //#state.java:110: end of method: bool net.sourceforge.pebble.domain.State.equals(Object)
  }

  /**
   * Returns a String representation of this object.
   *
   * @return  a String
   */
  public String toString() {
    return this.name;
    //#state.java:119: method: String net.sourceforge.pebble.domain.State.toString()
    //#input(String toString()): this
    //#input(String toString()): this.name
    //#output(String toString()): return_value
    //#pre[2] (String toString()): init'ed(this.name)
    //#post(String toString()): return_value == this.name
    //#post(String toString()): init'ed(return_value)
    //#state.java:119: end of method: String net.sourceforge.pebble.domain.State.toString()
  }

}
    //#state.java:: end of class: net.sourceforge.pebble.domain.State
