Enum Class JSONCodecFactorySupplier
- All Implemented Interfaces:
Serializable,Comparable<JSONCodecFactorySupplier>,Constable
JSONCodecFactory instances.- Author:
- Robert Varga
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionSource ofJSONCodecFactoryinstances compliant with draft-lhotka-netmod-yang-json-02.Source ofJSONCodecFactoryinstances compliant with RFC7951. -
Method Summary
Modifier and TypeMethodDescription@NonNull JSONCodecFactorycreateLazy(@NonNull org.opendaylight.yangtools.yang.model.api.EffectiveModelContext context) Create a new thread-unsafe, lazily-cachingJSONCodecFactoryfor a SchemaContext.@NonNull JSONCodecFactorycreateSimple(@NonNull org.opendaylight.yangtools.yang.model.api.EffectiveModelContext context) Create a simplistic, thread-safeJSONCodecFactoryfor aEffectiveModelContext.@NonNull JSONCodecFactorygetPrecomputed(@NonNull org.opendaylight.yangtools.yang.model.api.EffectiveModelContext context) Get a thread-safe, eagerly-cachingJSONCodecFactoryfor a SchemaContext.@NonNull Optional<JSONCodecFactory>getPrecomputedIfAvailable(@NonNull org.opendaylight.yangtools.yang.model.api.EffectiveModelContext context) Get a thread-safe, eagerly-cachingJSONCodecFactoryfor a SchemaContext, if it is available.@NonNull JSONCodecFactorygetShared(@NonNull org.opendaylight.yangtools.yang.model.api.EffectiveModelContext context) Get a thread-safe, lazily-cachingJSONCodecFactoryfor a SchemaContext.static JSONCodecFactorySupplierReturns the enum constant of this class with the specified name.static JSONCodecFactorySupplier[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
RFC7951
Source ofJSONCodecFactoryinstances compliant with RFC7951. -
DRAFT_LHOTKA_NETMOD_YANG_JSON_02
Source ofJSONCodecFactoryinstances compliant with draft-lhotka-netmod-yang-json-02.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getPrecomputed
public @NonNull JSONCodecFactory getPrecomputed(@NonNull org.opendaylight.yangtools.yang.model.api.EffectiveModelContext context) Get a thread-safe, eagerly-cachingJSONCodecFactoryfor a SchemaContext. This method can, and will, return the same instance as long as the associated SchemaContext is present. Returned object can be safely used by multiple threads concurrently. If the SchemaContext instance does not have a cached instance ofJSONCodecFactory, it will be completely precomputed before this method will return.Choosing this implementation is appropriate when the memory overhead of keeping a full codec tree is not as great a concern as predictable performance. When compared to the implementation returned by
getShared(EffectiveModelContext), this implementation is expected to offer higher performance and have lower peak memory footprint when most of the SchemaContext is actually in use.For call sites which do not want to pay the CPU cost of pre-computing this implementation, but still would like to use it if is available (by being populated by some other caller), you can use
getPrecomputedIfAvailable(EffectiveModelContext).- Parameters:
context- SchemaContext instance- Returns:
- A sharable
JSONCodecFactory - Throws:
NullPointerException- if context is null
-
getPrecomputedIfAvailable
public @NonNull Optional<JSONCodecFactory> getPrecomputedIfAvailable(@NonNull org.opendaylight.yangtools.yang.model.api.EffectiveModelContext context) Get a thread-safe, eagerly-cachingJSONCodecFactoryfor a SchemaContext, if it is available. This method is a non-blocking equivalent ofgetPrecomputed(EffectiveModelContext)for use in code paths where the potential of having to pre-compute the implementation is not acceptable. One such scenario is when the code base wants to opportunistically take advantage of pre-computed version, but is okay with a fallback to a different implementation.- Parameters:
context- SchemaContext instance- Returns:
- A sharable
JSONCodecFactory, or absent if such an implementation is not available. - Throws:
NullPointerException- if context is null
-
createLazy
public @NonNull JSONCodecFactory createLazy(@NonNull org.opendaylight.yangtools.yang.model.api.EffectiveModelContext context) Create a new thread-unsafe, lazily-cachingJSONCodecFactoryfor a SchemaContext. This method will return distinct objects every time it is invoked. Returned object may not be used from multiple threads concurrently.This implementation is appropriate for one-off serialization from a single thread. It will aggressively cache codecs for reuse and will tie them up in memory until the factory is freed.
- Parameters:
context- SchemaContext instance- Returns:
- A non-sharable
JSONCodecFactory - Throws:
NullPointerException- if context is null
-
createSimple
public @NonNull JSONCodecFactory createSimple(@NonNull org.opendaylight.yangtools.yang.model.api.EffectiveModelContext context) Create a simplistic, thread-safeJSONCodecFactoryfor aEffectiveModelContext. This method will return distinct objects every time it is invoked. Returned object may be use from multiple threads concurrently.This implementation exists mostly for completeness only, as it does not perform any caching at all and each codec is computed every time it is requested. This may be useful in extremely constrained environments, where memory footprint is more critical than performance.
- Parameters:
context- SchemaContext instance- Returns:
- A non-sharable
JSONCodecFactory - Throws:
NullPointerException- if context is null.
-