Top Description Inners Fields Constructors Methods
org.springframework.aot.hint.predicate

public Class ResourceHintsPredicates

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List, java.util.function.Predicate, java.util.regex.Pattern, org.springframework.aot.hint.ResourceHints, .ResourcePatternHint, .RuntimeHints, .TypeReference, org.springframework.util.Assert, .ConcurrentLruCache

Generator of ResourceHints predicates, testing whether the given hints match the expected behavior for resources.
Authors
Brian Clozel, Stephane Nicoll, Sam Brannen
Since
6.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
private static final ConcurrentLruCache<ResourcePatternHint, Pattern>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Predicate<RuntimeHints>

Returns:

the RuntimeHints predicate
forBundle
(String
the resource bundle name
bundleName
)

Return a predicate that checks whether a resource hint is registered for the given bundle name.

public Predicate<RuntimeHints>

Returns:

the RuntimeHints predicate
forResource
(TypeReference
the type's package where to look for the resource
type
,
String
the resource name
resourceName
)

Return a predicate that checks whether a resource hint is registered for the given resource name, located in the given type's package.

public Predicate<RuntimeHints>

Returns:

the RuntimeHints predicate
forResource
(String
the absolute resource name
resourceName
)

Return a predicate that checks whether a resource hint is registered for the given resource name.

private String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CACHED_RESOURCE_PATTERNSback to summary
private static final ConcurrentLruCache<ResourcePatternHint, Pattern> CACHED_RESOURCE_PATTERNS

Constructor Detail

ResourceHintsPredicatesback to summary
pack-priv ResourceHintsPredicates()

Method Detail

forBundleback to summary
public Predicate<RuntimeHints> forBundle(String bundleName)

Return a predicate that checks whether a resource hint is registered for the given bundle name.

Parameters
bundleName:String

the resource bundle name

Returns:Predicate<RuntimeHints>

the RuntimeHints predicate

forResourceback to summary
public Predicate<RuntimeHints> forResource(TypeReference type, String resourceName)

Return a predicate that checks whether a resource hint is registered for the given resource name, located in the given type's package.

For example, forResource(org.example.MyClass, "myResource.txt") will match against "org/example/myResource.txt".

If the given resource name is an absolute path (i.e., starts with a leading slash), the supplied type will be ignored. For example, forResource(org.example.MyClass, "/myResource.txt") will match against "myResource.txt".

Parameters
type:TypeReference

the type's package where to look for the resource

resourceName:String

the resource name

Returns:Predicate<RuntimeHints>

the RuntimeHints predicate

forResourceback to summary
public Predicate<RuntimeHints> forResource(String resourceName)

Return a predicate that checks whether a resource hint is registered for the given resource name.

A leading slash will be removed.

Parameters
resourceName:String

the absolute resource name

Returns:Predicate<RuntimeHints>

the RuntimeHints predicate

resolveAbsoluteResourceNameback to summary
private String resolveAbsoluteResourceName(TypeReference type, String resourceName)
org.springframework.aot.hint.predicate back to summary

private final Record ResourceHintsPredicates.AggregatedResourcePatternHints

extends Record
Class Inheritance
Record Components
includes:List<ResourcePatternHint> 
excludes:List<ResourcePatternHint> 

Field Summary

Modifier and TypeField and Description
private final List<ResourcePatternHint>
excludes

Record Component accessed by excludes().

private final List<ResourcePatternHint>
includes

Record Component accessed by includes().

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.
public List<ResourcePatternHint>
excludes()

Record Component getter of excludes.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.
public List<ResourcePatternHint>
includes()

Record Component getter of includes.

pack-priv static ResourceHintsPredicates.AggregatedResourcePatternHints
of(ResourceHints resourceHints)

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

excludesback to summary
private final List<ResourcePatternHint> excludes

Record Component accessed by excludes().

includesback to summary
private final List<ResourcePatternHint> includes

Record Component accessed by includes().

Constructor Detail

AggregatedResourcePatternHintsback to summary
private AggregatedResourcePatternHints(List<ResourcePatternHint> includes, List<ResourcePatternHint> excludes)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this record is equal to the argument; false otherwise.

excludesback to summary
public List<ResourcePatternHint> excludes()

Record Component getter of excludes.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Returns:int

a hash code value for this record.

includesback to summary
public List<ResourcePatternHint> includes()

Record Component getter of includes.

ofback to summary
pack-priv static ResourceHintsPredicates.AggregatedResourcePatternHints of(ResourceHints resourceHints)
toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Returns:String

a string representation of the object.