]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils/src/org/simantics/utils/ExtendableDataContainer.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.utils / src / org / simantics / utils / ExtendableDataContainer.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 /*\r
13  * Created on 16.12.2005\r
14  * \r
15  */\r
16 package org.simantics.utils;\r
17 \r
18 \r
19 /**\r
20  * DataContainer is used as return argument\r
21  * \r
22  * \r
23  * @author Toni Kalajainen \r
24  */\r
25 public class ExtendableDataContainer<T> {\r
26 \r
27     private T data;\r
28     \r
29     public ExtendableDataContainer() {       \r
30     }\r
31     \r
32     public ExtendableDataContainer(T initialData) {\r
33         this.data = initialData;\r
34     }\r
35     \r
36     public boolean isEmpty() {\r
37         return data==null;\r
38     }\r
39     \r
40     public void set(T value) {\r
41         data = value;\r
42     }\r
43     \r
44     public T get() {\r
45         return data;\r
46     }\r
47     \r
48     public boolean hasContent() {\r
49         return data!=null;\r
50     }\r
51     \r
52     public static ExtendableDataContainer<Integer> getIntegerContainer() {\r
53         return new ExtendableDataContainer<Integer>();\r
54     }\r
55         \r
56     public static ExtendableDataContainer<Double> getDoubleContainer() {\r
57         return new ExtendableDataContainer<Double>();\r
58     }\r
59         \r
60     public static ExtendableDataContainer<String> getStringContainer() {\r
61         return new ExtendableDataContainer<String>();\r
62     }\r
63         \r
64 }\r