Package net.sf.basedb.util.listable
Class SourceItemTransformerWithCache
- java.lang.Object
-
- net.sf.basedb.util.listable.SourceItemTransformerWithCache
-
- All Implemented Interfaces:
SourceItemTransformerFactory
public class SourceItemTransformerWithCache extends Object implements SourceItemTransformerFactory
This is a wrapper transformer factory that can be applied to any other factory in order to provide support for caching. The cache holds the result fromSourceItemTransformer.transform(TransformContext, Set)
so that if the same set of source ids are provided it will pick the cache result if available and only forward to the wrapped factory in case no old result exists or if it is too old.- Since:
- 3.16
- Author:
- Nicklas
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
SourceItemTransformerWithCache.TransformerWithCache
-
Field Summary
Fields Modifier and Type Field Description private SourceItemTransformerFactory
factory
-
Constructor Summary
Constructors Constructor Description SourceItemTransformerWithCache(SourceItemTransformerFactory factory)
Create a new source item transformer chain.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SourceItemTransformer
create(Item sourceItemType, SyncFilter.SourceItemTransform transform)
Create a source item transformed that can transform between the given source item and theSourceItemTransformerFactory.getTargetItem()
.List<Item>
getSupportedSourceItems(SyncFilter.SourceItemTransform transform)
Get the supported source item types when transforming in the specified direction.Item
getTargetItem()
Get the target item type of this transformer factory.
-
-
-
Field Detail
-
factory
private final SourceItemTransformerFactory factory
-
-
Constructor Detail
-
SourceItemTransformerWithCache
public SourceItemTransformerWithCache(SourceItemTransformerFactory factory)
Create a new source item transformer chain. The chain must contain at least one element and all steps must have matching source and target item types.- Throws:
IllegalArgumentException
- If the chain is null or empty or have non-matching transformation steps
-
-
Method Detail
-
getTargetItem
public Item getTargetItem()
Description copied from interface:SourceItemTransformerFactory
Get the target item type of this transformer factory. All transformers created by this factory are expected to have a matchingSourceItemTransformer.getTargetItemType()
.- Specified by:
getTargetItem
in interfaceSourceItemTransformerFactory
-
getSupportedSourceItems
public List<Item> getSupportedSourceItems(SyncFilter.SourceItemTransform transform)
Description copied from interface:SourceItemTransformerFactory
Get the supported source item types when transforming in the specified direction. TheSourceItemTransformerFactory.create(Item, SyncFilter.SourceItemTransform)
method should be able to create aSourceItemTransformer
for all of the item types returned by this method.- Specified by:
getSupportedSourceItems
in interfaceSourceItemTransformerFactory
-
create
public SourceItemTransformer create(Item sourceItemType, SyncFilter.SourceItemTransform transform)
Description copied from interface:SourceItemTransformerFactory
Create a source item transformed that can transform between the given source item and theSourceItemTransformerFactory.getTargetItem()
. Calling this method with an unsupported combination should result in a null return value.- Specified by:
create
in interfaceSourceItemTransformerFactory
-
-