Class ContentValue
- java.lang.Object
-
- com.stackone.stackone_client_java.models.components.ContentValue
-
public class ContentValue extends java.lang.ObjectWrapper class for an "open" enum. "Open" enums are those that are expected to evolve (particularly with the addition of enum members over time). If an open enum is used then the appearance of unexpected enum values (say in a response from an updated an API) will not bring about a runtime error thus ensuring that non-updated client versions can continue to work without error.
Note that instances are immutable and are singletons (an internal thread-safe cache is maintained to ensure that). As a consequence instances created with the same value will satisfy reference equality (via
==).This class is intended to emulate an enum (in terms of common usage and with reference equality) but with the ability to carry unknown values. Unfortunately Java does not permit the use of an instance in a switch expression but you can use the
asEnum()method (after dealing with the `Optional` appropriately).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classContentValue._Deserializerstatic classContentValue._Serializerstatic classContentValue.ContentValueEnum
-
Field Summary
Fields Modifier and Type Field Description static ContentValueARTICLEstatic ContentValueAUDIOstatic ContentValueDOCUMENTstatic ContentValueQUIZstatic ContentValueUNMAPPED_VALUEstatic ContentValueVIDEO
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<ContentValue.ContentValueEnum>asEnum()booleanequals(java.lang.Object obj)inthashCode()booleanisKnown()static ContentValueof(java.lang.String value)Returns a ContentValue with the given value.java.lang.StringtoString()java.lang.Stringvalue()static ContentValue[]values()
-
-
-
Field Detail
-
VIDEO
public static final ContentValue VIDEO
-
QUIZ
public static final ContentValue QUIZ
-
DOCUMENT
public static final ContentValue DOCUMENT
-
AUDIO
public static final ContentValue AUDIO
-
ARTICLE
public static final ContentValue ARTICLE
-
UNMAPPED_VALUE
public static final ContentValue UNMAPPED_VALUE
-
-
Method Detail
-
of
public static ContentValue of(java.lang.String value)
Returns a ContentValue with the given value. For a specific value the returned object will always be a singleton so reference equality is satisfied when the values are the same.- Parameters:
value- value to be wrapped as ContentValue
-
value
public java.lang.String value()
-
asEnum
public java.util.Optional<ContentValue.ContentValueEnum> asEnum()
-
isKnown
public boolean isKnown()
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
values
public static ContentValue[] values()
-
-