diff --git a/lib/java/src/org/apache/thrift/Option.java b/lib/java/src/org/apache/thrift/Option.java index db25ec513..d5cd309e8 100644 --- a/lib/java/src/org/apache/thrift/Option.java +++ b/lib/java/src/org/apache/thrift/Option.java @@ -24,6 +24,9 @@ package org.apache.thrift; */ public abstract class Option { + @SuppressWarnings("rawtypes") + private static final Option NONE = new None(); + /** * Whether the Option is defined or not * @return @@ -87,7 +90,7 @@ public abstract class Option { } public String toString() { - return "Some("+value.toString()+")"; + return "Some(" + value + ")"; } } @@ -99,9 +102,9 @@ public abstract class Option { */ public static Option fromNullable(T value) { if (value != null) { - return new Some(value); + return some(value); } else { - return new None(); + return none(); } } @@ -115,7 +118,8 @@ public abstract class Option { return new Some(value); } + @SuppressWarnings("unchecked") public static None none() { - return new None(); + return (None) NONE; } } \ No newline at end of file