Enum Class AttributeContextDependency
- All Implemented Interfaces:
Serializable,Comparable<AttributeContextDependency>,Constable
Allows the attribute loader to declare that the value it produces is calculated using some of the values from the context.
Different context dependencies may have different effects. Some, like USER_LOCALE, provide "compartments" for values,
allowing to efficiently cache values for each locale. Some, like CURRENT_TIME, declare the dependency on time and the corresponding
caching rules will be applied.
Context dependencies propagate through dependencies. Making an attribute dependent on the current user will also make all dependent attribute dependent on the current user.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe values depend on the current time.The values depend on the structure that they are being shown in.The values depend on some items, which will be added viaAttributeLoaderContext.addTrail(com.almworks.jira.structure.api.attribute.loader.TrailItemSet).The values depend on the current user.The values depend on the current user's locale.The values depend on the current user's time zone. -
Method Summary
Modifier and TypeMethodDescriptionstatic Set<AttributeContextDependency>guessContextDependencies(AttributeSpec<?> spec) static Set<AttributeContextDependency>union(Set<AttributeContextDependency> set, AttributeContextDependency... additional) static AttributeContextDependencyReturns the enum constant of this class with the specified name.static AttributeContextDependency[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
USER
The values depend on the current user.
The values will be calculated separately for each individual user (including anonymous user).
Use
AttributeContext.getUser()when calculating the value to get the current user.This context dependency supersedes
USER_LOCALEandUSER_TIMEZONE. No need to declare these context dependencies, since the user compartment already provides the necessary separation for different locales and time zones.All values with this context dependency will be invalidated when the user itself is changed.
-
USER_LOCALE
The values depend on the current user's locale. Typically this is used when calculating a HTML-rendered value.
The values will be calculated separately for each locale. If two users have the same locale, they will share the same value.
Use
AttributeContext.getLocale()orAttributeContext.getI18nHelper()when calculating the value. -
USER_TIMEZONE
The values depend on the current user's time zone.
The values will be calculated separately for each time zone. If two users have the same time zone, they will share the same value.
Use
AttributeContext.getTimeZone()when calculating the value. -
STRUCTURE
The values depend on the structure that they are being shown in.
The values may depend only on the structure ID, without any transformations. When calculating the values for a query-based forest, the structure ID will be equal to
0, and so all the values calculated for queries will be shared.Note that forest-dependent attributes will naturally be stored in a forest-specific cache. There's no need to declare structure dependency for aggregates, for example. You only need to declare the dependency if you actively use the structure ID for calculating the value. For example, you can store different values for the same items in different structures.
Use
AttributeContext.getBaseStructureId()when calculating the value. -
CURRENT_TIME
The values depend on the current time.
Declaring this context dependency will cause the values to expire after some time and get recalculated. You can define the expiration time by calling
AttributeLoaderContext.valueExpires(long, java.util.concurrent.TimeUnit), or just declare the context dependency and go with the default expiration.You can use
AttributeContext.getLoadTimeMillis()andAttributeContext.getLoadTimeNanos()when calculating the value. These methods will return a consistent number for all values loaded in the same loading process. But you can also useSystem.currentTimeMillis()andSystem.nanoTime(). -
TRAIL
The values depend on some items, which will be added via
AttributeLoaderContext.addTrail(com.almworks.jira.structure.api.attribute.loader.TrailItemSet).You need to declare this dependency in order for the system to be prepared for the
addTrail()call. In particular, multi-row attributes that declare this dependency will not be eligible for pre-validation (reusing a previously calculated value if nothing has changed in the inputs).Note that you don't need to declare this dependency if you're declaring a global trail via
AttributeLoader.getGlobalTrail().
-
-
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
-
guessContextDependencies
-
union
@NotNull public static Set<AttributeContextDependency> union(@Nullable Set<AttributeContextDependency> set, @Nullable AttributeContextDependency... additional)
-