2 * jFCPlib - UserObject.java - Copyright © 2009 David Roden
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package net.pterodactylus.util.thread;
22 * Wrapper around an object that can be set and retrieved. Its primary use is as
23 * a container for return values from anonymous classes.
26 * final ObjectWrapper<Object> objectWrapper = new ObjectWrapper<Object>();
30 * objectWrapper.set(someResult);
33 * Object result = objectWrapper.get();
37 * The type of the wrapped object
38 * @author David ‘Bombe’ Roden <bombe@pterodactylus.net>
40 public class ObjectWrapper<T> {
42 /** The wrapped object. */
43 private volatile T wrappedObject;
46 * Returns the wrapped object.
48 * @return The wrapped object
55 * Sets the wrapped object.
57 * @param wrappedObject
60 public void set(T wrappedObject) {
61 this.wrappedObject = wrappedObject;