View Javadoc

    1   /*
    2    * joey-gen and its relative products are published under the terms
    3    * of the Apache Software License.
    4    *
    5    * Created on 2004/10/27 2:01:00
    6    */
    7   package org.asyrinx.joey.gen.model;
    8
    9   import org.apache.commons.lang.builder.EqualsBuilder;
    10
    11
    12  /***
    13   * @author takeshi
    14   */
    15  public abstract class AbstractEnumeration extends ElementSet {
    16
    17      /***
    18       *
    19       */
    20      public AbstractEnumeration() {
    21          super((String) null);
    22      }
    23
    24      /***
    25       *
    26       */
    27      public AbstractEnumeration(Element parent, String name) {
    28          this(parent, name, "int");
    29      }
    30
    31      /***
    32       *
    33       */
    34      public AbstractEnumeration(Element parent, String name, String type) {
    35          super(parent, name);
    36          this.valueType = type;
    37      }
    38
    39      /*
    40       * (non-Javadoc)
    41       *
    42       * @see org.asyrinx.joey.gen.model.ElementSet#isEntity()
    43       */
    44      public boolean isEntity() {
    45          return true;
    46      }
    47
    48      private String valueType = "int";
    49
    50      /*
    51       * (non-Javadoc)
    52       *
    53       * @see org.asyrinx.joey.gen.model.ElementSet#add(org.asyrinx.joey.gen.model.Element)
    54       */
    55      public void add(EnumerationEntry entry) {
    56          super.add(entry);
    57      }
    58
    59      /*
    60       * (non-Javadoc)
    61       *
    62       * @see org.asyrinx.joey.gen.model.ElementSet#contains(org.asyrinx.joey.gen.model.Element)
    63       */
    64      public boolean contains(EnumerationEntry entry) {
    65          return super.contains(entry);
    66      }
    67
    68      /*
    69       * (non-Javadoc)
    70       *
    71       * @see org.asyrinx.joey.gen.model.ElementSet#getElement(int)
    72       */
    73      public EnumerationEntry getEntry(int index) {
    74          return (EnumerationEntry) super.getElement(index);
    75      }
    76
    77      /*
    78       * (non-Javadoc)
    79       *
    80       * @see org.asyrinx.joey.gen.model.ElementSet#get(java.lang.String)
    81       */
    82      public EnumerationEntry getEntry(String name) {
    83          return (EnumerationEntry) super.getElement(name);
    84      }
    85
    86      /*
    87       * (non-Javadoc)
    88       *
    89       * @see org.asyrinx.joey.gen.model.ElementSet#remove(java.lang.String)
    90       */
    91      public EnumerationEntry removeEntry(String name) {
    92          return (EnumerationEntry) super.removeElement(name);
    93      }
    94
    95      /***
    96       * @return Returns the valueType.
    97       */
    98      public String getValueType() {
    99          return valueType;
    100     }
    101
    102     /***
    103      * @param valueType
    104      *               The valueType to set.
    105      */
    106     public void setValueType(String type) {
    107         this.valueType = type;
    108     }
    109
    110     /*
    111      * (non-Javadoc)
    112      *
    113      * @see java.lang.Object#equals(java.lang.Object)
    114      */
    115     public boolean equals(Object obj) {
    116         if (!super.equals(obj))
    117             return false;
    118         if (!(obj instanceof AbstractEnumeration))
    119             return false;
    120         final AbstractEnumeration other = (AbstractEnumeration) obj;
    121         return new EqualsBuilder() //
    122                 .append(this.getValueType(), other.getValueType()) //
    123                 .isEquals();
    124     }
    125
    126 }