Class MetaParams
- java.lang.Object
-
- org.infinispan.functional.impl.MetaParams
-
@NotThreadSafe @Experimental public final class MetaParams extends Object implements Iterable<MetaParam<?>>
Represents aMetaParam
collection.In
Params
, the internal array where each parameter was stored is indexed by an integer. This worked fine because the available parameters are exclusively controlled by the Infinispan. This is not the case withMetaParam
instances where users are expected to add their own types. So, forMetaParams
, an array is still used but the lookup is done sequentially comparing the type of theMetaParam
looked for against the each individualMetaParam
instance stored inMetaParams
.Having sequential
MetaParam
lookups over an array is O(n), but this is not problematic since the number ofMetaParam
to be stored with each cached entry is expected to be small, less than 10 perMetaParams
collection. So, the performance impact is quite small.Storing
MetaParam
instances in an array adds the least amount of overhead to keeping a collection ofMetaParam
in memory along with each cached entry, while retaining flexibility to add or removeMetaParam
instances.This
MetaParams
collection is not thread safe because it is expected that any updates will be done having acquired write locks on the entireCacheEntry
which references theMetaParams
collection. Hence, any updates could be done without the need to keepMetaParams
concurrently safe. Also, although users can retrieve or update individualMetaParam
instances, they cannot act on the globally at theMetaParams
level, and hence there is no risk of users misusingMetaParams
. This class should not be accessible from user code, therefore it is package-protected.- Since:
- 8.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(MetaParam meta)
void
addMany(MetaParam... metaParams)
MetaParams
copy()
<T extends MetaParam>
Optional<T>find(Class<T> type)
boolean
isEmpty()
Iterator<MetaParam<?>>
iterator()
static MetaParams
readFrom(ObjectInput input)
<T extends MetaParam>
voidremove(Class<T> type)
<T extends MetaParam>
voidreplace(Class<T> type, Function<T,T> f)
int
size()
Spliterator<MetaParam<?>>
spliterator()
String
toString()
static void
writeTo(ObjectOutput output, MetaParams params)
-
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
-
size
public int size()
-
copy
public MetaParams copy()
-
add
public void add(MetaParam meta)
-
addMany
public void addMany(MetaParam... metaParams)
-
spliterator
public Spliterator<MetaParam<?>> spliterator()
- Specified by:
spliterator
in interfaceIterable<MetaParam<?>>
-
readFrom
public static MetaParams readFrom(ObjectInput input) throws IOException, ClassNotFoundException
- Throws:
IOException
ClassNotFoundException
-
writeTo
public static void writeTo(ObjectOutput output, MetaParams params) throws IOException
- Throws:
IOException
-
-