thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "BELUGA BEHR (JIRA)" <j...@apache.org>
Subject [jira] [Created] (THRIFT-4711) Improve Immutable None Type Instantiation
Date Tue, 01 Jan 2019 19:41:00 GMT
BELUGA BEHR created THRIFT-4711:
-----------------------------------

             Summary: Improve Immutable None Type Instantiation
                 Key: THRIFT-4711
                 URL: https://issues.apache.org/jira/browse/THRIFT-4711
             Project: Thrift
          Issue Type: Improvement
          Components: Java - Library
    Affects Versions: 0.12.0
            Reporter: BELUGA BEHR


{code:title=Option.java}
    public static <T> Option<T> fromNullable(T value) {
        if (value != null) {
            return new Some<T>(value);
        } else {
            return new None<T>();
        }
    }
{code}

The {{None}} class is an immutable object, therefore it does not need to be instantiated for
every call to {{fromNullable}}.  Do the same thing as Java's {{Collections.emptyList()}} to
allow for a single static instance of {{None}} to return.

https://github.com/openjdk-mirror/jdk7u-jdk/blob/master/src/share/classes/java/util/Collections.java#L3178-L3180



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message