public class BaseItemAttributeLoader<T> extends BaseAttributeLoader<T> implements ItemAttributeLoader<T>
Constructor and Description |
---|
BaseItemAttributeLoader(AttributeSpec<T> attributeSpec,
Set<AttributeSpec<?>> dependencies,
Set<AttributeContextDependency> contextDependencies,
AttributeCachingStrategy cachingStrategy,
TrailItemSet globalTrail,
Predicate<String> itemTypeSupportedPredicate,
BiFunction<ItemIdentity,ItemAttributeContext,AttributeValue<T>> attributeFunction,
BiConsumer<Collection<ItemIdentity>,AttributeContext> preloadFunction) |
Modifier and Type | Method and Description |
---|---|
boolean |
isItemTypeSupported(String itemType)
Lets the loader declare if it can handle items of a given type.
|
AttributeValue<T> |
loadValue(ItemIdentity itemId,
ItemAttributeContext context)
The loading function.
|
void |
preload(Collection<ItemIdentity> itemIds,
AttributeContext context)
Optional method to perform any bulk actions on a set of items before
ItemAttributeLoader.loadValue(com.almworks.jira.structure.api.item.ItemIdentity, com.almworks.jira.structure.api.attribute.loader.ItemAttributeContext) method is called for each item in the collection. |
getAttributeDependencies, getAttributeSpec, getCachingStrategy, getContextDependencies, getGlobalTrail
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAttributeDependencies, getAttributeSpec, getCachingStrategy, getContextDependencies, getGlobalTrail
public BaseItemAttributeLoader(@NotNull AttributeSpec<T> attributeSpec, @Nullable Set<AttributeSpec<?>> dependencies, @Nullable Set<AttributeContextDependency> contextDependencies, @Nullable AttributeCachingStrategy cachingStrategy, @Nullable TrailItemSet globalTrail, @Nullable Predicate<String> itemTypeSupportedPredicate, @NotNull BiFunction<ItemIdentity,ItemAttributeContext,AttributeValue<T>> attributeFunction, @Nullable BiConsumer<Collection<ItemIdentity>,AttributeContext> preloadFunction)
public boolean isItemTypeSupported(@NotNull String itemType)
ItemAttributeLoader
Lets the loader declare if it can handle items of a given type. If the loader returns false
for some type, its ItemAttributeLoader.loadValue(com.almworks.jira.structure.api.item.ItemIdentity, com.almworks.jira.structure.api.attribute.loader.ItemAttributeContext)
function will not be called for items of that type; also, non-supported items will be excluded from the collection passed to ItemAttributeLoader.preload(java.util.Collection<com.almworks.jira.structure.api.item.ItemIdentity>, com.almworks.jira.structure.api.attribute.loader.AttributeContext)
method.
The returned value must be the same for the same item type throughout the lifetime of the object.
isItemTypeSupported
in interface ItemAttributeLoader<T>
itemType
- the type of itemItemIdentity
@Nullable public AttributeValue<T> loadValue(@NotNull ItemIdentity itemId, @NotNull ItemAttributeContext context)
ItemAttributeLoader
The loading function. The implementation is expected to take itemId
or the item object (see ItemAttributeContext.getItem(java.lang.Class<I>)
)
and provide a value.
Attribute system's contract:
ItemAttributeLoader.isItemTypeSupported(java.lang.String)
method has been called at least once for the type of the
passed item, and this loader has returned true
.ItemAttributeLoader.preload(java.util.Collection<com.almworks.jira.structure.api.item.ItemIdentity>, com.almworks.jira.structure.api.attribute.loader.AttributeContext)
has been called for a set of items that included itemId
, and that was
a part of the same loading process, sharing the same context (so all values put into the context are still there).If the value is missing or empty, the loader should return AttributeValue.undefined()
. If for some reason this loader
is not applicable for the given item, it should return null
.
loadValue
in interface ItemAttributeLoader<T>
itemId
- item to load the value forcontext
- loading contextnull
to pass on loading a value for this itempublic void preload(@NotNull Collection<ItemIdentity> itemIds, @NotNull AttributeContext context)
ItemAttributeLoader
Optional method to perform any bulk actions on a set of items before ItemAttributeLoader.loadValue(com.almworks.jira.structure.api.item.ItemIdentity, com.almworks.jira.structure.api.attribute.loader.ItemAttributeContext)
method is called for each item in the collection.
The results of the preloading should be stored using AttributeContext.putObject(java.lang.Object, java.lang.Object)
.
Do not store the preloading results as loader's instance fields! All loaders should be stateless.
Note that this method may be called several times during a single loading operation, for arbitrary sets of items, including those already pre-loaded. Be careful not to overwrite one execution's result with another's.
When this method is called, the attribute system excludes any non-supported items from the list of passed items
(checking ItemAttributeLoader.isItemTypeSupported(java.lang.String)
).
The loader's dependencies may not be loaded at the time of the call. In fact, there's no way to access the dependency values.
preload
in interface ItemAttributeLoader<T>
itemIds
- a collection of item IDs about to be loadedcontext
- loading contextCopyright © 2024 Tempo Software. All Rights Reserved.