1ec74feb19acaaef0b26f0d11fa29f37fb152cc3
[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 final value would 
20  * 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      * @param aValue Value. 
39      */
40     public ValueHolder(T aValue) { 
41         value = aValue; 
42     }
43     
44     /**
45      * @return Current value. 
46      */
47     public T getValue() {
48         return value;
49     }
50     
51     /**
52      * Set the value. 
53      * @param aValue New value. 
54      */
55     public void setValue(T aValue) {
56         value = aValue;
57     }
58 }