Package edu.wisc.game.sql

## Class Piece

- java.lang.Object
- - edu.wisc.game.sql.Piece

- All Implemented Interfaces:
    `Serializable`

      @Entity
      public class Piece
      extends Object
      implements Serializable

  Represents a piece of a specified type at a specified location. Used in board description.

       "boardObjectsArrays":{
           "Cvu0lwRnl":{
           "id":"Cvu0lwRnl",
           "value":
           [{"color":"yellow","shape":"square","id":"1","x":1,"y":1},
           {"color":"black","shape":"square","id":"6","x":6,"y":1},
           {"color":"red","shape":"square","id":"31","x":1,"y":6},
           {"color":"blue","shape":"square","id":"36","x":6,"y":6}],
           "name":"Four squares in corners"}
           }
      }

  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `Piece.Color` |
    `static class` | `Piece.PseudoEnum` | A flexible replacement for an Enum
    `static class` | `Piece.Shape` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Piece()` |
    `Piece​(Piece.Shape _shape, Piece.Color _color, int _x, int _y)` | Creates a traditional (shape+color) game piece placed at a specified location.
    `Piece​(String _image, int _x, int _y)` | Creates an IPB game piece placed at a specified location.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `boolean` | `equals​(Object o)` | This method is oversimplified, because it's normally expected that the ID is unique within a board
    `int[]` | `getBuckets()` |
    `String` | `getColor()` | This method is used just for Jersey/REST, to simplify JSON output structure, making it similar to that used in Game Engine 1.0
    `Integer` | `getDropped()` |
    `HashMap<String,​Object>` | `getExtraFields()` | This method is discovered by Reflect, and is then used when converting IPB objects to JSON (via Reflect), to add "name:value" pairs for all non-legacy properties.
    `long` | `getId()` |
    `String` | `getImage()` |
    `ImageObject` | `getImageObject()` |
    `String` | `getLabel()` |
    `String` | `getProperty​(String name)` |
    `String` | `getShape()` | For JSON
    `int` | `getX()` |
    `int` | `getY()` |
    `int` | `hashCode()` | Compares all properties
    `String` | `objectType()` |
    `Board.Pos` | `pos()` |
    `void` | `setBoard​(Board _board)` |
    `void` | `setBuckets​(int[] _buckets)` |
    `void` | `setColor​(Piece.Color x)` | This is how it used by our JsonToJava, when reading board files
    `void` | `setDropped​(Integer _dropped)` |
    `void` | `setId​(long _id)` |
    `void` | `setImage​(String _image)` |
    `void` | `setLabel​(String _label)` |
    `void` | `setShape​(Piece.Shape x)` | This is how it used by our JsonToJava
    `void` | `setX​(int _x)` |
    `void` | `setY​(int _y)` |
    `String` | `toString()` |
    `Piece.Color` | `xgetColor()` |
    `Board.Pos` | `xgetPos()` |
    `Piece.Shape` | `xgetShape()` | For use in our application

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Piece

          public Piece()

    - #### Piece

          public Piece​(Piece.Shape _shape,
                       Piece.Color _color,
                       int _x,
                       int _y)

      Creates a traditional (shape+color) game piece placed at a specified location.

    - #### Piece

          public Piece​(String _image,
                       int _x,
                       int _y)

      Creates an IPB game piece placed at a specified location.
      Parameters:
        `image` - the image identifier

  - ### Method Detail

    - #### setBoard

          public void setBoard​(Board _board)

    - #### getId

          public long getId()

    - #### setId

          public void setId​(long _id)

    - #### getImage

          public String getImage()

    - #### setImage

          public void setImage​(String _image)

    - #### getProperty

          public String getProperty​(String name)

      Returns:
        null for a S+C object; the value of the specified property for an IPB object

    - #### getImageObject

          public ImageObject getImageObject()

      Returns:
        If this is an IPB or Composite object, return the corresponding ImageObject; otherwise null.

    - #### xgetColor

          public Piece.Color xgetColor()

    - #### getColor

          public String getColor()

      This method is used just for Jersey/REST, to simplify JSON output structure, making it similar to that used in Game Engine 1.0

    - #### setColor

          public void setColor​(Piece.Color x)

      This is how it used by our JsonToJava, when reading board files

    - #### getShape

          public String getShape()

      For JSON

    - #### setShape

          public void setShape​(Piece.Shape x)

      This is how it used by our JsonToJava

    - #### xgetShape

          public Piece.Shape xgetShape()

      For use in our application

    - #### objectType

          public String objectType()

    - #### getX

          public int getX()

    - #### setX

          public void setX​(int _x)

    - #### getY

          public int getY()

    - #### setY

          public void setY​(int _y)

    - #### xgetPos

          public Board.Pos xgetPos()

    - #### getDropped

          public Integer getDropped()

    - #### setDropped

          public void setDropped​(Integer _dropped)

    - #### getLabel

          public String getLabel()

    - #### setLabel

          public void setLabel​(String _label)

    - #### equals

          public boolean equals​(Object o)

      This method is oversimplified, because it's normally expected that the ID is unique within a board
      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Compares all properties
      Overrides:
        `hashCode` in class `Object`

    - #### pos

          public Board.Pos pos()

    - #### getBuckets

          public int[] getBuckets()

    - #### setBuckets

          public void setBuckets​(int[] _buckets)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### getExtraFields

          public HashMap<String,​Object> getExtraFields()

      This method is discovered by Reflect, and is then used when converting IPB objects to JSON (via Reflect), to add "name:value" pairs for all non-legacy properties. Since toPropMap is used,