| IntegerWrapper.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 */
14
15 package com.liferay.portal.kernel.util;
16
17 /**
18 * <a href="IntegerWrapper.java.html"><b><i>View Source</i></b></a>
19 *
20 * @author Brian Wing Shun Chan
21 */
22 public class IntegerWrapper
23 extends PrimitiveWrapper implements Comparable<IntegerWrapper> {
24
25 public static final Class<?> TYPE = Integer.TYPE;
26
27 public IntegerWrapper() {
28 this(0);
29 }
30
31 public IntegerWrapper(int value) {
32 _value = value;
33 }
34
35 public int compareTo(IntegerWrapper integerWrapper) {
36 if (integerWrapper == null) {
37 return 1;
38 }
39
40 if (getValue() > integerWrapper.getValue()) {
41 return 1;
42 }
43 else if (getValue() < integerWrapper.getValue()) {
44 return -1;
45 }
46 else {
47 return 0;
48 }
49 }
50
51 public int getValue() {
52 return _value;
53 }
54
55 public void setValue(int value) {
56 _value = value;
57 }
58
59 public int increment() {
60 return ++_value;
61 }
62
63 public int decrement() {
64 return --_value;
65 }
66
67 private int _value;
68
69 }