Last change
on this file since 1097 was 1097, checked in by davidb, 6 years ago |
Newly structured files from Corey's work on logic/graphics separation
|
File size:
956 bytes
|
Line | |
---|
1 | package org.expeditee.core;
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * A wrapper type to allow the ability to pass values by reference.
|
---|
5 | *
|
---|
6 | * @author cts16
|
---|
7 | */
|
---|
8 | public class InOutReference<T> {
|
---|
9 |
|
---|
10 | /** The value of this reference. */
|
---|
11 | private T _value;
|
---|
12 |
|
---|
13 | /** Default constructor. */
|
---|
14 | public InOutReference()
|
---|
15 | {
|
---|
16 | _value = null;
|
---|
17 | }
|
---|
18 |
|
---|
19 | /** Standard constructor. */
|
---|
20 | public InOutReference(T value)
|
---|
21 | {
|
---|
22 | _value = value;
|
---|
23 | }
|
---|
24 |
|
---|
25 | /** Copy constructor. */
|
---|
26 | public InOutReference(InOutReference<T> other)
|
---|
27 | {
|
---|
28 | this(other._value);
|
---|
29 | }
|
---|
30 |
|
---|
31 | /** Gets the value of this reference (dereferences). */
|
---|
32 | public T get()
|
---|
33 | {
|
---|
34 | return _value;
|
---|
35 | }
|
---|
36 |
|
---|
37 | /** Sets the value of this reference. */
|
---|
38 | public void set(T value)
|
---|
39 | {
|
---|
40 | _value = value;
|
---|
41 | }
|
---|
42 |
|
---|
43 | @Override
|
---|
44 | public InOutReference<T> clone()
|
---|
45 | {
|
---|
46 | return new InOutReference<T>(this);
|
---|
47 | }
|
---|
48 |
|
---|
49 | @Override
|
---|
50 | public boolean equals(Object other)
|
---|
51 | {
|
---|
52 | if (other instanceof InOutReference<?>) {
|
---|
53 | return ((InOutReference<?>) other)._value.equals(_value);
|
---|
54 | }
|
---|
55 |
|
---|
56 | return false;
|
---|
57 | }
|
---|
58 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.