Debian Codegraph @

src/com/bulenkov/iconloader/util/Ref.java

raw symbols SCIP
1 /*
2 * Copyright 2000-2014 JetBrains s.r.o.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.bulenkov.iconloader.util;
18
19 /**
20 * @author Konstantin Bulenkov
21 */
22 public class Ref<T> {
23 private T myValue;
24
25 public Ref() {
26 }
27
28 public Ref(T value) {
29 myValue = value;
30 }
31
32 public boolean isNull() {
33 return myValue == null;
34 }
35
36 public T get() {
37 return myValue;
38 }
39
40 public void set(T value) {
41 myValue = value;
42 }
43
44 public boolean setIfNull(T value) {
45 if (myValue == null) {
46 myValue = value;
47 return true;
48 }
49 return false;
50 }
51
52 public static <V> Ref<V> create() {
53 return new Ref<V>();
54 }
55
56 public static <V> Ref<V> create(V value) {
57 return new Ref<V>(value);
58 }
59
60 @Override
61 public String toString() {
62 return String.valueOf(myValue);
63 }
64 }