Creating an expandable enum type, converting StorageClass#1937
Conversation
|
Updates #1832 |
shinfan
left a comment
There was a problem hiding this comment.
The design looks reasonable to me. Just a few comments.
| * Get the StorageClass for the given String constant, and throw an exception if the constant is | ||
| * not recognized. | ||
| */ | ||
| public static StorageClass valueOfStrict(String constant) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| public abstract class StringEnumValue { | ||
| private String constant; | ||
|
|
||
| @InternalApi |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| public StringEnumType(String enumName, ApiFunction<String, EnumT> constructor) { | ||
| this.enumName = enumName; | ||
| this.constructor = constructor; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| private final String enumName; | ||
| private final ApiFunction<String, EnumT> constructor; | ||
| private Map<String, EnumT> knownValues = new HashMap<>(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Design looks good to me too. Two points: (1) Is may be possible to push some functionality from |
|
(1) Which functionality can be moved up? The only public things in |
|
Changes Unknown when pulling 6db00d3 on garrettjonesgoogle:alt into ** on GoogleCloudPlatform:master**. |
|
Re (1): you are right. |
|
Added unit tests, PTAL |
|
Changes Unknown when pulling d6f19ab on garrettjonesgoogle:alt into ** on GoogleCloudPlatform:master**. |
|
Changes Unknown when pulling ded5357 on garrettjonesgoogle:alt into ** on GoogleCloudPlatform:master**. |
|
LGTM |
Design notes:
valueOfandvalues, same as Java enums)