Interface AttributeLoaderContext
- All Superinterfaces:
AttributeContext
- All Known Subinterfaces:
AggregateAttributeContext
,DerivedAttributeContext
,ItemAttributeContext
,PropagateAttributeContext
,RowAttributeContext
,ScanningAttributeContext
,SingleRowAttributeContext
This interface adds methods to AttributeContext
that are used only by attribute loaders.
Each type of attribute loader will receive a more specific type of context with additional methods based on what that type of loaders might need.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTrail
(TrailItemSet trail) Used to indicate the trail of the value being calculated.default void
addTrail
(ItemIdentity item) Used to indicate the trail of the value being calculated.<V> AttributeValue<V>
getDependencyAttributeValue
(AttributeSpec<V> dependency) Gets the value of dependency attribute for the row being calculated.default <V> V
getDependencyValue
(AttributeSpec<V> dependency) Gets the value of dependency attribute for the row being calculated.void
valueExpires
(long ttl, TimeUnit unit) Calling this method makes the value being currently calculated expire by timeout.Methods inherited from interface AttributeContext
getBaseStructureId, getBaseUrl, getI18n, getI18nHelper, getLoadTimeMillis, getLoadTimeNanos, getLocale, getObject, getTimeZone, getUser, putObject
-
Method Details
-
getDependencyAttributeValue
Gets the value of dependency attribute for the row being calculated.
The loader must declare the dependency in order to get its value here. The attribute system guarantees that the dependency attributes are loaded first.
- Type Parameters:
V
- type of the value- Parameters:
dependency
- attribute spec of the dependency- Returns:
- value of the dependency, as
AttributeValue
wrapper - Throws:
IllegalArgumentException
- if the dependency attribute was not declared- See Also:
-
getDependencyValue
Gets the value of dependency attribute for the row being calculated.
The loader must declare the dependency in order to get its value here. The attribute system guarantees that the dependency attributes are loaded first.
- Type Parameters:
V
- type of the value- Parameters:
dependency
- attribute spec of the dependency- Returns:
- value of the dependency
- Throws:
IllegalArgumentException
- if the dependency attribute was not declared- See Also:
-
addTrail
Used to indicate the trail of the value being calculated.
A trail is an additional set of items that were used to produce the value for the currently calculated row or item. It is important to indicate the trail because when those additional items change, we need to recalculate this value.
For example, if we calculate the display name of the issue's assignee, we use the corresponding "user" object. Even if the issue's assignee does not later change, the user's display name might, so in order to catch that and recalculate the value, we need add the user item as the trail for this value.
Attribute loaders are required to declare
AttributeContextDependency.TRAIL
to use this method.- Parameters:
trail
- the set of items used to calculate this value
-
addTrail
Used to indicate the trail of the value being calculated.
Attribute loaders are required to declare
AttributeContextDependency.TRAIL
to use this method.- Parameters:
item
- a single item that was used to calculate this value- See Also:
-
valueExpires
Calling this method makes the value being currently calculated expire by timeout. When the value expires, it becomes outdated and will be recalculated the next time it is requested.
Any value that depends on one or more expiring values will also have an expiration time equal to the earliest expiration time of its dependencies.
Calling this method multiple times will result in the earliest expiration time being used.
Attribute loaders are required to declare
AttributeContextDependency.CURRENT_TIME
to use this method.If
CURRENT_TIME
context dependency is declared, butvalueExpires()
is not called, a default expiration period will be used. It is set to 30 seconds and can be changed via settingstructure.attribute.timedValueRefresh
dark feature (in milliseconds).- Parameters:
ttl
- amount of time after which the currently calculated value should expire, must be a positive numberunit
- time unit- Throws:
IllegalArgumentException
- ifttl <= 0
- See Also:
-