    View Javadoc
    1   /*
    2    * Copyright (c) 2003
    3    * Information Desire GmbH
    4    * All rights reserved.
    5    */
    6   package com.infodesire.infobit.dao;
    7
    8   import java.io.Serializable;
    9   import org.apache.commons.lang.builder.HashCodeBuilder;
    10  import org.apache.commons.logging.Log;
    11  import org.apache.commons.logging.LogFactory;
    12
    13  /***
    14   * base class for infobit entities with simple keys
    15   *
    16   * @author    konstantin
    17   * @created   July 29, 2003
    18   * @version   $Revision: 1.3 $
    19   */
    20  class BaseEntityImpl implements Serializable {
    21      private static Log _log = LogFactory.getLog(BaseEntityImpl.class);
    22
    23      private Integer _id;
    24
    25      private Integer _hashCode = null;
    26
    27
    28      /***
    29       * @return         The Id value
    30       * @hibernate.id   unsaved-value="null" generator-class="native"
    31       */
    32      public Integer getId() {
    33          return _id;
    34      }
    35
    36
    37      /***
    38       * Sets the Id attribute of the BaseEntity object
    39       *
    40       * @param id  The new Id value
    41       */
    42      public void setId(Integer id) {
    43          _id = id;
    44      }
    45
    46
    47      /***
    48       * test for entity equality. for entities to be equal they have to be the
    49       * same class and have equal assigned identity ( not null )
    50       *
    51       * @param o  oibject to comnpare to
    52       * @return   euqllity status for another entity
    53       */
    54      public boolean equals(Object o) {
    55          if (o == null) {
    56              if (_log.isDebugEnabled()) {
    57                  _log.debug(this + " " + getId() + " does not equals to null");
    58              }
    59              return false;
    60          }
    61          if (_log.isDebugEnabled()) {
    62              _log.debug(this + " " + getId() + " does  equals to " + o + ":" + (hashCode() == o.hashCode()));
    63          }
    64
    65          return hashCode() == o.hashCode();
    66      }
    67
    68
    69      /***
    70       * @return   hash code suitable for comparison
    71       */
    72      public int hashCode() {
    73          if (null == _hashCode) {
    74              _hashCode = new Integer(new HashCodeBuilder(17, 37)
    75                  .append(_id)
    76                  .append(getClass())
    77                  .toHashCode());
    78          }
    79          return _hashCode.intValue();
    80      }
    81
    82  }

This page was automatically generated by Maven