| 1 |
// Test case for Issue 596: |
| 2 |
// https://github.com/typetools/checker-framework/issues/596 |
| 3 |
|
| 4 |
import java.util.concurrent.atomic.AtomicReference; |
| 5 |
import org.checkerframework.checker.nullness.qual.*; |
| 6 |
|
| 7 |
class Issue596 { |
| 8 |
|
| 9 |
private static String getOrEmpty(AtomicReference<String> ref) { |
| 10 |
return Optional596.fromNullable(ref.get()).or(""); |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
// From Google Guava |
| 15 |
class Optional596<T> { |
| 16 |
|
| 17 |
public static <T> Optional596<T> fromNullable(@Nullable T nullableReference) { |
| 18 |
return new Optional596<T>(); |
| 19 |
} |
| 20 |
|
| 21 |
public T or(T defaultValue) { |
| 22 |
return defaultValue; |
| 23 |
} |
| 24 |
} |