K - key typepublic class ConstantContainer<K> extends Object implements Container<K>, Container.Lifecycle
A container that stores key-value pairs.
Supports the following factory methods to create containers:
forMap(java.lang.String, java.util.Map<K, ?>): key-value pairs in the specified map;forEnum(java.lang.String, java.lang.Class<T>, java.util.function.Function<? super T, ? extends K>): enumeration type, key or value is the enumeration attribute value;forConstantClass(java.lang.Class<?>, cn.crane4j.core.support.AnnotationFinder): static constants attribute in the specified class;for performance reasons, when get data from container, it always returns all data which set in the creation time. and data will not be updated after the container is created.
ContainerEnumContainer.LifecycleEMPTY_CONTAINER_NAMESPACE| 构造器和说明 |
|---|
ConstantContainer() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
destroy()
Destroy the container
|
static ConstantContainer<Object> |
forConstantClass(Class<?> constantClass,
AnnotationFinder annotationFinder)
Convert public static constants in the specified constant class to containers.
|
static <K> ConstantContainer<K> |
forEnum(Class<? extends Enum<?>> enumType,
AnnotationFinder annotationFinder,
PropertyOperator propertyOperator)
Create a key-value pair container based on the specified type enumeration.
|
static <K,T extends Enum<?>> |
forEnum(String namespace,
Class<T> enumType,
Function<? super T,? extends K> keyGetter)
Create a key-value pair container based on the specified type enumeration.
|
static <K> ConstantContainer<K> |
forMap(String namespace,
Map<K,?> data)
Create a key-value pair container based on the specified type enumeration.
|
Map<K,?> |
get(Collection<K> keys)
Enter a batch of key values to return data source objects grouped by key values.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitempty, getNamespaceinitpublic static <K,T extends Enum<?>> @NonNull ConstantContainer<K> forEnum(String namespace, Class<T> enumType, Function<? super T,? extends K> keyGetter)
Create a key-value pair container based on the specified type enumeration.
The key value is the enumeration attribute value obtained by keyGetter.
K - key typeT - enumeration typenamespace - namespaceenumType - enum typekeyGetter - method to obtain the corresponding key value from the enumeration comparatorpublic static <K> ConstantContainer<K> forEnum(Class<? extends Enum<?>> enumType, AnnotationFinder annotationFinder, PropertyOperator propertyOperator)
Create a key-value pair container based on the specified type enumeration.
The key value and namespace are obtained through the corresponding ContainerEnum annotation
enumType - enum typeannotationFinder - annotation finderpropertyOperator - property operatorContainerEnumpublic static ConstantContainer<Object> forConstantClass(Class<?> constantClass, AnnotationFinder annotationFinder)
constantClass - constant classContainerConstantpublic static <K> ConstantContainer<K> forMap(String namespace, Map<K,?> data)
Create a key-value pair container based on the specified type enumeration.
The key value is the enumeration attribute value obtained by keyGetter.
K - key typenamespace - namespacedata - data source objects grouped by key valuepublic Map<K,?> get(Collection<K> keys)
public void destroy()
destroy 在接口中 Container.LifecycleCopyright © 2023. All rights reserved.