Project

General

Profile

« Previous | Next » 

Revision 794be65e

Added by Andreas Müller almost 2 years ago

cleanup

View differences:

cdmlib-commons/src/main/java/eu/etaxonomy/cdm/common/ResultWrapper.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.cdm.common;
11

  
12
import org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.Logger;
14

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

  
37
	private static final Logger logger = LogManager.getLogger(ResultWrapper.class);
38

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

  
46
	private T object;
47

  
48
	public T getValue() {
49
		return object;
50
	}
51

  
52
	public void setValue(T value) {
53
		this.object = value;
54
	}
55
}
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.cdm.common;
11

  
12
import org.apache.logging.log4j.LogManager;
13
import org.apache.logging.log4j.Logger;
14

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

  
37
	private static final Logger logger = LogManager.getLogger();
38

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

  
46
	private T object;
47

  
48
	public T getValue() {
49
		return object;
50
	}
51

  
52
	public void setValue(T value) {
53
		this.object = value;
54
	}
55
}

Also available in: Unified diff