Enum Class PredefinedAnnotationRenderStrategy
- All Implemented Interfaces:
Serializable
,Comparable<PredefinedAnnotationRenderStrategy>
,Constable
AnnotationRenderStrategy
as enum values.
It also provides helper methods to store/retrieve the strategy for a document via
getStrategyFrom(Document)
and applyToDocument(Document)
respectively.
General background
The annotation render strategies will be used on client and server side. By using this enum, no
serialization / reflection is needed to get the strategy.
To apply an AnnotationRenderStrategy, the DocumentDataProvider implementation must set the
desired PredefinedAnnotationRenderStrategy
on a document. The client and server side
renderers will then use this strategy to check if they should render the annotation.
To apply a strategy in a renderer implementation, the following 3 steps are required:
- Retrieve the enum value from the document properties via
getStrategyFrom(Document)
- Get the concrete
AnnotationRenderStrategy
from the enum value viagetStrategy()
- Delegate the call to
AnnotationRenderStrategy.accept(Annotation, Document)
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAnnotations shall always be rendered on the client side, regardless of their permissions.Annotations shall be rendered on server side, if the DENY.REMOVE and DENY.CHANGE permissions are present on the annotation. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PredefinedAnnotationRenderStrategy
The default strategy to be used if no strategy is explicitly set on the document. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyToDocument
(Document document) This server-side call applies one of the PredefinedAnnotationRenderStrategies to the given document.getPredefinedStrategyFrom
(Document document) Returns thePredefinedAnnotationRenderStrategy
for the given document.Returns the underlyingAnnotationRenderStrategy
, which defined the rendering behavior of the annotations.static AnnotationRenderStrategy
getStrategyFrom
(Document document) Returns theAnnotationRenderStrategy
for the given document.Returns the enum constant of this class with the specified name.static PredefinedAnnotationRenderStrategy[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
CLIENT
Annotations shall always be rendered on the client side, regardless of their permissions. -
SERVER_SIDE_MASKING
Annotations shall be rendered on server side, if the DENY.REMOVE and DENY.CHANGE permissions are present on the annotation. This represents the default behavior.
-
-
Field Details
-
DEFAULT_STRATEGY
The default strategy to be used if no strategy is explicitly set on the document. Value:CLIENT
-
-
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
-
getStrategy
Returns the underlyingAnnotationRenderStrategy
, which defined the rendering behavior of the annotations.- Returns:
- the
AnnotationRenderStrategy
-
getStrategyFrom
Returns theAnnotationRenderStrategy
for the given document. If there is an entry in the document properties with keyPROPERTY_KEY
, that value will be used to return the AnnotationRenderStrategy to apply. If no property entry is present, or the entry does not point to a valid enum name, the default strategy will be returned.This method mainly is for JWT-internal use.
- Parameters:
document
- The document- Returns:
- the
AnnotationRenderStrategy
to use for this document (never null)
-
getPredefinedStrategyFrom
Returns thePredefinedAnnotationRenderStrategy
for the given document. If there is an entry in the document properties with keyPROPERTY_KEY
, that value will be used. If no entry is present, or the entry does not point to a valid enum name, theDEFAULT_STRATEGY
will be returned.This method may come handy when the integrating application needs client-side access to the render strategy in order to enforce different behaviour depending on the strategy that was configured server-side.
- Parameters:
document
- The document- Returns:
- the
PredefinedAnnotationRenderStrategy
to use (never null). One of CLIENT, SERVER_SIDE_MASKING and DEFAULT_STRATEGY.
-
applyToDocument
This server-side call applies one of the PredefinedAnnotationRenderStrategies to the given document. Make sure this call is made very early from withinDocumentDataProvider.read(com.levigo.jadice.document.read.Reader, com.levigo.jadice.web.shared.model.Source)
, before reading any document streams.- Parameters:
document
- The document to apply the current PredefinedAnnotationRenderStrategy to. Transportation takes place in a document property.
-