Package org.apache.maven.impl.cache
Record Class CacheConfig
java.lang.Object
java.lang.Record
org.apache.maven.impl.cache.CacheConfig
- Record Components:
scope- the cache retention scopereferenceType- the reference type to use for cache entries (backward compatibility)keyReferenceType- the reference type to use for keys (null means use referenceType)valueReferenceType- the reference type to use for values (null means use referenceType)
public record CacheConfig(CacheRetention scope, Cache.ReferenceType referenceType, Cache.ReferenceType keyReferenceType, Cache.ReferenceType valueReferenceType)
extends Record
Configuration for cache behavior including scope and reference types.
Supports separate reference types for keys and values to enable fine-grained
control over eviction behavior and better cache miss analysis.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CacheConfigDefault cache configuration with REQUEST_SCOPED and SOFT reference type. -
Constructor Summary
ConstructorsConstructorDescriptionCacheConfig(CacheRetention scope, Cache.ReferenceType referenceType) Backward compatibility constructor.CacheConfig(CacheRetention scope, Cache.ReferenceType referenceType, Cache.ReferenceType keyReferenceType, Cache.ReferenceType valueReferenceType) Creates an instance of aCacheConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.Returns the effective key reference type.Returns the effective value reference type.final inthashCode()Returns a hash code value for this object.booleanReturns true if this configuration uses separate reference types for keys and values.Returns the value of thekeyReferenceTyperecord component.Returns the value of thereferenceTyperecord component.scope()Returns the value of thescoperecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thevalueReferenceTyperecord component.static CacheConfigwithKeyValueReferenceTypes(CacheRetention scope, Cache.ReferenceType keyReferenceType, Cache.ReferenceType valueReferenceType) Creates a cache configuration with separate key and value reference types.static CacheConfigwithReferenceType(Cache.ReferenceType referenceType) Creates a cache configuration with the specified reference type and default REQUEST_SCOPED scope.static CacheConfigwithScope(CacheRetention scope) Creates a cache configuration with the specified scope and default SOFT reference type.
-
Field Details
-
DEFAULT
Default cache configuration with REQUEST_SCOPED and SOFT reference type.
-
-
Constructor Details
-
CacheConfig
Backward compatibility constructor. -
CacheConfig
public CacheConfig(CacheRetention scope, Cache.ReferenceType referenceType, Cache.ReferenceType keyReferenceType, Cache.ReferenceType valueReferenceType) Creates an instance of aCacheConfigrecord class.- Parameters:
scope- the value for thescoperecord componentreferenceType- the value for thereferenceTyperecord componentkeyReferenceType- the value for thekeyReferenceTyperecord componentvalueReferenceType- the value for thevalueReferenceTyperecord component
-
-
Method Details
-
withScope
Creates a cache configuration with the specified scope and default SOFT reference type. -
withReferenceType
Creates a cache configuration with the specified reference type and default REQUEST_SCOPED scope. -
withKeyValueReferenceTypes
public static CacheConfig withKeyValueReferenceTypes(CacheRetention scope, Cache.ReferenceType keyReferenceType, Cache.ReferenceType valueReferenceType) Creates a cache configuration with separate key and value reference types. -
getEffectiveKeyReferenceType
Returns the effective key reference type. -
getEffectiveValueReferenceType
Returns the effective value reference type. -
hasSeparateKeyValueReferenceTypes
public boolean hasSeparateKeyValueReferenceTypes()Returns true if this configuration uses separate reference types for keys and values. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
scope
Returns the value of thescoperecord component.- Returns:
- the value of the
scoperecord component
-
referenceType
Returns the value of thereferenceTyperecord component.- Returns:
- the value of the
referenceTyperecord component
-
keyReferenceType
Returns the value of thekeyReferenceTyperecord component.- Returns:
- the value of the
keyReferenceTyperecord component
-
valueReferenceType
Returns the value of thevalueReferenceTyperecord component.- Returns:
- the value of the
valueReferenceTyperecord component
-