@PublicApi public interface AttributeLoaderContext extends AttributeContext
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.
Modifier and Type | Method and Description |
---|---|
default void |
addTrail(ItemIdentity item)
Used to indicate the trail of the value being calculated.
|
void |
addTrail(TrailItemSet trail)
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.
|
getBaseStructureId, getBaseUrl, getI18n, getI18nHelper, getLoadTimeMillis, getLoadTimeNanos, getLocale, getObject, getTimeZone, getUser, putObject
@NotNull <V> AttributeValue<V> getDependencyAttributeValue(@NotNull AttributeSpec<V> dependency)
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.
V
- type of the valuedependency
- attribute spec of the dependencyAttributeValue
wrapperIllegalArgumentException
- if the dependency attribute was not declaredAttributeLoader.getAttributeDependencies()
@Nullable default <V> V getDependencyValue(@NotNull AttributeSpec<V> dependency)
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.
V
- type of the valuedependency
- attribute spec of the dependencyIllegalArgumentException
- if the dependency attribute was not declaredAttributeLoader.getAttributeDependencies()
void addTrail(@Nullable TrailItemSet trail)
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.
trail
- the set of items used to calculate this valuedefault void addTrail(@Nullable ItemIdentity item)
Used to indicate the trail of the value being calculated.
Attribute loaders are required to declare AttributeContextDependency.TRAIL
to use this method.
item
- a single item that was used to calculate this valueaddTrail(TrailItemSet)
void valueExpires(long ttl, @NotNull TimeUnit unit)
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, but valueExpires()
is not called, a default expiration period will
be used. It is set to 30 seconds and can be changed via setting structure.attribute.timedValueRefresh
dark feature (in milliseconds).
ttl
- amount of time after which the currently calculated value should expire, must be a positive numberunit
- time unitIllegalArgumentException
- if ttl <= 0
AttributeLoader
,
AttributeLoader.getContextDependencies()
Copyright © 2024 Tempo Software. All Rights Reserved.