001 /* 002 * (c) 2003-2005, 2009, 2010 ThoughtWorks Ltd 003 * All rights reserved. 004 * 005 * The software in this package is published under the terms of the BSD 006 * style license a copy of which has been included with this distribution in 007 * the LICENSE.txt file. 008 * 009 * Created on 17-May-2004 010 */ 011 package com.thoughtworks.proxy.kit; 012 013 import java.io.Serializable; 014 015 /** 016 * Simple implementation for an {@link ObjectReference}. 017 * 018 * @author Aslak Hellesøy 019 * @since 0.2 020 */ 021 public class SimpleReference<T> implements ObjectReference<T>, Serializable { 022 private static final long serialVersionUID = 1L; 023 private T instance; 024 025 /** 026 * Construct a SimpleReference. 027 * 028 * @param reference The referenced object. 029 * @since 0.2 030 */ 031 public SimpleReference(final T reference) { 032 set(reference); 033 } 034 035 public T get() { 036 return instance; 037 } 038 039 public void set(final T item) { 040 this.instance = item; 041 } 042 }