@Beta public enum JSONCodecFactorySupplier extends Enum<JSONCodecFactorySupplier>
JSONCodecFactory
instances.Enum Constant and Description |
---|
DRAFT_LHOTKA_NETMOD_YANG_JSON_02
Source of
JSONCodecFactory instances compliant with RFC7951. |
RFC7951
Source of
JSONCodecFactory instances compliant with RFC7951. |
Modifier and Type | Method and Description |
---|---|
@NonNull JSONCodecFactory |
createLazy(@NonNull SchemaContext context)
Create a new thread-unsafe, lazily-caching
JSONCodecFactory for a SchemaContext. |
@NonNull JSONCodecFactory |
createSimple(@NonNull SchemaContext context)
Create a simplistic, thread-safe
JSONCodecFactory for a SchemaContext . |
@NonNull JSONCodecFactory |
getPrecomputed(@NonNull SchemaContext context)
Get a thread-safe, eagerly-caching
JSONCodecFactory for a SchemaContext. |
@NonNull Optional<JSONCodecFactory> |
getPrecomputedIfAvailable(@NonNull SchemaContext context)
Get a thread-safe, eagerly-caching
JSONCodecFactory for a SchemaContext, if it is available. |
@NonNull JSONCodecFactory |
getShared(@NonNull SchemaContext context)
Get a thread-safe, lazily-caching
JSONCodecFactory for a SchemaContext. |
static JSONCodecFactorySupplier |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static JSONCodecFactorySupplier[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final JSONCodecFactorySupplier RFC7951
JSONCodecFactory
instances compliant with RFC7951.public static final JSONCodecFactorySupplier DRAFT_LHOTKA_NETMOD_YANG_JSON_02
JSONCodecFactory
instances compliant with RFC7951.public static JSONCodecFactorySupplier[] values()
for (JSONCodecFactorySupplier c : JSONCodecFactorySupplier.values()) System.out.println(c);
public static JSONCodecFactorySupplier valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic @NonNull JSONCodecFactory getPrecomputed(@NonNull SchemaContext context)
JSONCodecFactory
for 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
of JSONCodecFactory
, 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(SchemaContext)
, 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(SchemaContext)
.
context
- SchemaContext instanceJSONCodecFactory
NullPointerException
- if context is nullpublic @NonNull Optional<JSONCodecFactory> getPrecomputedIfAvailable(@NonNull SchemaContext context)
JSONCodecFactory
for a SchemaContext, if it is available. This
method is a non-blocking equivalent of getPrecomputed(SchemaContext)
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.context
- SchemaContext instanceJSONCodecFactory
, or absent if such an implementation is not available.NullPointerException
- if context is nullpublic @NonNull JSONCodecFactory getShared(@NonNull SchemaContext context)
JSONCodecFactory
for a SchemaContext. This method can, and will,
return the same instance as long as the associated SchemaContext is present or the factory is not invalidated
by memory pressure. Returned object can be safely used by multiple threads concurrently.
Choosing this implementation is a safe default, as it will not incur prohibitive blocking, nor will it tie up memory in face of pressure.
context
- SchemaContext instanceJSONCodecFactory
NullPointerException
- if context is nullpublic @NonNull JSONCodecFactory createLazy(@NonNull SchemaContext context)
JSONCodecFactory
for 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.
context
- SchemaContext instanceJSONCodecFactory
NullPointerException
- if context is nullpublic @NonNull JSONCodecFactory createSimple(@NonNull SchemaContext context)
JSONCodecFactory
for a SchemaContext
. 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.
context
- SchemaContext instanceJSONCodecFactory
NullPointerException
- if context is null.Copyright © 2019 OpenDaylight. All rights reserved.