View Javadoc

1   /**
2    * Copyright (c) 2008-2011, http://www.snakeyaml.org
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.yaml.snakeyaml.immutable.primitives;
18  
19  public class BunchOfPrimitives {
20      private int primitiveInt;
21      private double primitiveDouble;
22      public boolean primitiveBoolean;
23  
24      public BunchOfPrimitives(int primitiveInt, double primitiveDouble, boolean primitiveBoolean) {
25          this.primitiveInt = primitiveInt;
26          this.primitiveDouble = primitiveDouble;
27          this.primitiveBoolean = primitiveBoolean;
28      }
29  
30      /**
31       * The number of parameters is the same but the type is different
32       */
33      public BunchOfPrimitives(int i1, int i2, int i3) {
34          this.primitiveInt = i1;
35      }
36  
37      public BunchOfPrimitives(long i1, double i2, boolean i3) {
38          this((int) i1, i2, i3);
39      }
40  
41      public int getPrimitiveInt() {
42          return primitiveInt;
43      }
44  
45      public double getPrimitiveDouble() {
46          return primitiveDouble;
47      }
48  
49      @Override
50      public boolean equals(Object obj) {
51          if (obj instanceof BunchOfPrimitives) {
52              BunchOfPrimitives bunch = (BunchOfPrimitives) obj;
53              return primitiveInt == bunch.primitiveInt;
54          } else {
55              return false;
56          }
57      }
58  
59      @Override
60      public int hashCode() {
61          return primitiveInt;
62      }
63  
64      @Override
65      public String toString() {
66          return "BunchOfPrimitives " + primitiveInt;
67      }
68  }