KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opensubsystems > core > util > FourIntStruct


1 /*
2  * Copyright (c) 2003 - 2007 OpenSubsystems s.r.o. Slovak Republic. All rights reserved.
3  *
4  * Project: OpenSubsystems
5  *
6  * $Id: FourIntStruct.java,v 1.5 2007/01/07 06:14:00 bastafidli Exp $
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */

21
22 package org.opensubsystems.core.util;
23
24 /**
25  * Class which can hold four integers. This is useful if I want to create array of
26  * four integers to pass as argument to some function.
27  *
28  * @version $Id: FourIntStruct.java,v 1.5 2007/01/07 06:14:00 bastafidli Exp $
29  * @author Martin Cerba
30  * @code.reviewer Miro Halas
31  * @code.reviewed 1.3 2005/07/29 07:36:24 bastafidli
32  */

33 public class FourIntStruct extends ThreeIntStruct
34 {
35    // Attributes ///////////////////////////////////////////////////////////////
36

37    /**
38     * Fourth integer
39     */

40    protected int m_iFourth;
41
42    // Constructors /////////////////////////////////////////////////////////////
43

44    /**
45     * @param iFirst - first int
46     * @param iSecond - second int
47     * @param iThird - third int
48     * @param iFourth - fourth int
49     */

50    public FourIntStruct(
51       int iFirst,
52       int iSecond,
53       int iThird,
54       int iFourth
55    )
56    {
57       super(iFirst, iSecond, iThird);
58       
59       m_iFourth = iFourth;
60    }
61
62    // Logic ////////////////////////////////////////////////////////////////////
63

64    /**
65     * @return fourth integer
66     */

67    public int getFourth()
68    {
69       return m_iFourth;
70    }
71
72    /**
73     * {@inheritDoc}
74     */

75    public boolean equals(
76       Object JavaDoc oObject
77    )
78    {
79       boolean bRetval = false;
80       if (oObject == this)
81       {
82          return true;
83       }
84       else if (oObject != null)
85       {
86          if (oObject instanceof FourIntStruct)
87          {
88             FourIntStruct input = (FourIntStruct) oObject;
89             return (super.equals(oObject)) && (m_iFourth == input.m_iFourth);
90          }
91       }
92       return bRetval;
93    }
94
95    /**
96     * {@inheritDoc}
97     */

98    public int hashCode()
99    {
100       int iResult = HashCodeUtils.SEED;
101       iResult = HashCodeUtils.hash(iResult, m_iFourth);
102       iResult = HashCodeUtils.hash(iResult, super.hashCode());
103       return iResult;
104    }
105 }
106
Popular Tags