(no commit message)
[utils] / support / general / src / main / java / org / wamblee / general / ValueHolder.java
1 /*
2  * Copyright 2005-2010 the original author or authors.
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 package org.wamblee.general;
17
18 /**
19  * Object that holds a value of some type. This can be used where a mutable
20  * final value would be preferred.
21  * 
22  * @author Erik Brakkee
23  * 
24  */
25 public class ValueHolder<T> {
26
27     private T value;
28
29     /**
30      * Constructs with null value.
31      */
32     public ValueHolder() {
33         value = null;
34     }
35
36     /**
37      * Constructs with given value.
38      * 
39      * @param aValue
40      *            Value.
41      */
42     public ValueHolder(T aValue) {
43         value = aValue;
44     }
45
46     /**
47      * @return Current value.
48      */
49     public T getValue() {
50         return value;
51     }
52
53     /**
54      * Set the value.
55      * 
56      * @param aValue
57      *            New value.
58      */
59     public void setValue(T aValue) {
60         value = aValue;
61     }
62 }