Project

General

Profile

Download (1.69 KB) Statistics
| Branch: | Tag: | Revision:
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
5
* http://www.e-taxonomy.eu
6
* 
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

    
11
package eu.etaxonomy.cdm.common;
12

    
13
import org.apache.log4j.Logger;
14

    
15
//import org.apache.log4j.Logger;
16

    
17
/**
18
 * Wrapps a result object so it can be used as method parameter and changed within the method.
19
 * This is useful especially for simple data types like <code>Boolean</code> etc.<br>
20
 * Example (usage):<br><code>
21
 * 	public String myMethod(String oneParameter, ResultWrapper<Boolean> success){<br>
22
 * 	    __if (oneParameter.equals("foo")){<br>
23
 * 	    ____success = success.setValue(false);<br>
24
 * 	    ____return "Foo";<br>
25
 * 	__}else{<br>
26
 * 	____//don't change success<br>
27
 * 	____return "All the best";<br>
28
 * 	__}<br>
29
 * 	}
30
 * </code>
31
 * Here a String is returned but the boolean value may also be changed and it's value is useable 
32
 * by the calling method
33
 *  
34
 * @author a.mueller
35
 * @created 01.11.2008
36
 * @version 1.0
37
 */
38
public class ResultWrapper<T> {
39
	private static final Logger logger = Logger.getLogger(ResultWrapper.class);
40

    
41
	public static final ResultWrapper<Boolean> NewInstance(Boolean value){
42
		ResultWrapper<Boolean> result = new ResultWrapper<Boolean>();
43
		result.setValue(value);
44
		if (logger.isDebugEnabled()){logger.debug("New Instance");}
45
		return result;
46
	}
47
	
48
	T object;
49

    
50
	/**
51
	 * @return the object
52
	 */
53
	public T getValue() {
54
		return object;
55
	}
56

    
57
	/**
58
	 * @param object the object to set
59
	 */
60
	public void setValue(T value) {
61
		this.object = value;
62
	}
63
}
(13-13/20)