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

public Class ResourceHints

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashSet, .LinkedHashSet, .List, .Set, java.util.function.Consumer, java.util.stream.Stream, org.springframework.core.io.ClassPathResource, .Resource, org.springframework.lang.Nullable

Gather the need for resources available at runtime.
Authors
Stephane Nicoll, Sam Brannen
Since
6.0

Field Summary

Modifier and TypeField and Description
private final Set<ResourceBundleHint>
private final List<ResourcePatternHints>
private final Set<TypeReference>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public ResourceHints

Returns:

this, to facilitate method chaining
registerPattern
(Consumer<ResourcePatternHints.Builder>
a builder to further customize the resource pattern
resourceHint
)

Register that the resources matching the specified pattern should be made available at runtime.

public ResourceHints

Returns:

this, to facilitate method chaining
registerPattern
(String
a pattern of the resources to include (see ResourcePatternHint documentation)
include
)

Register that the resources matching the specified pattern should be made available at runtime.

public ResourceHints

Returns:

this, to facilitate method chaining
registerPatternIfPresent
(ClassLoader
the classloader to use
classLoader
,
String
a '/'-separated path name that should exist
location
,
Consumer<ResourcePatternHints.Builder>
a builder to customize the resource pattern
resourceHint
)

Register a pattern if the given location is available on the classpath.

public void
registerResource(Resource
the resource to register
resource
)

Register that the supplied resource should be made available at runtime.

public ResourceHints

Returns:

this, to facilitate method chaining
registerResourceBundle
(String
the base name of the resource bundle
baseName
,
Consumer<ResourceBundleHint.Builder>
a builder to further customize the resource bundle
resourceHint
)

Register that the resource bundle with the specified base name should be made available at runtime.

public ResourceHints

Returns:

this, to facilitate method chaining
registerResourceBundle
(String
the base name of the resource bundle
baseName
)

Register that the resource bundle with the specified base name should be made available at runtime.

public ResourceHints

Returns:

this, to facilitate method chaining
registerType
(TypeReference
the type to include
type
)

Register that the bytecode of the type defined by the specified TypeReference should be made available at runtime.

public ResourceHints

Returns:

this, to facilitate method chaining
registerType
(Class<?>
the type to include
type
)

Register that the bytecode of the specified type should be made available at runtime.

public Stream<ResourceBundleHint>

Returns:

a stream of ResourceBundleHint
resourceBundleHints
()

Return the resource bundles that should be made available at runtime.

public Stream<ResourcePatternHints>

Returns:

a stream of ResourcePatternHints
resourcePatternHints
()

Return the resources that should be made available at runtime.

private String
private ResourcePatternHints
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

resourceBundleHintsback to summary
private final Set<ResourceBundleHint> resourceBundleHints
resourcePatternHintsback to summary
private final List<ResourcePatternHints> resourcePatternHints
typesback to summary
private final Set<TypeReference> types

Constructor Detail

ResourceHintsback to summary
public ResourceHints()

Method Detail

registerPatternback to summary
public ResourceHints registerPattern(Consumer<ResourcePatternHints.Builder> resourceHint)

Register that the resources matching the specified pattern should be made available at runtime.

Parameters
resourceHint:Consumer<ResourcePatternHints.Builder>

a builder to further customize the resource pattern

Returns:ResourceHints

this, to facilitate method chaining

registerPatternback to summary
public ResourceHints registerPattern(String include)

Register that the resources matching the specified pattern should be made available at runtime.

Parameters
include:String

a pattern of the resources to include (see ResourcePatternHint documentation)

Returns:ResourceHints

this, to facilitate method chaining

registerPatternIfPresentback to summary
public ResourceHints registerPatternIfPresent(ClassLoader classLoader, String location, Consumer<ResourcePatternHints.Builder> resourceHint)

Register a pattern if the given location is available on the classpath. This delegates to ClassLoader#getResource(String) which validates directories as well. The location is not included in the hint.

Parameters
classLoader:ClassLoader

the classloader to use

location:String

a '/'-separated path name that should exist

resourceHint:Consumer<ResourcePatternHints.Builder>

a builder to customize the resource pattern

Returns:ResourceHints

this, to facilitate method chaining

registerResourceback to summary
public void registerResource(Resource resource)

Register that the supplied resource should be made available at runtime.

Parameters
resource:Resource

the resource to register

Exceptions
IllegalArgumentException:
if the supplied resource is not a ClassPathResource or does not exist
See Also
registerPattern(String), ClassPathResource#getPath()
registerResourceBundleback to summary
public ResourceHints registerResourceBundle(String baseName, Consumer<ResourceBundleHint.Builder> resourceHint)

Register that the resource bundle with the specified base name should be made available at runtime.

Parameters
baseName:String

the base name of the resource bundle

resourceHint:Consumer<ResourceBundleHint.Builder>

a builder to further customize the resource bundle

Returns:ResourceHints

this, to facilitate method chaining

registerResourceBundleback to summary
public ResourceHints registerResourceBundle(String baseName)

Register that the resource bundle with the specified base name should be made available at runtime.

Parameters
baseName:String

the base name of the resource bundle

Returns:ResourceHints

this, to facilitate method chaining

registerTypeback to summary
public ResourceHints registerType(TypeReference type)

Register that the bytecode of the type defined by the specified TypeReference should be made available at runtime.

Parameters
type:TypeReference

the type to include

Returns:ResourceHints

this, to facilitate method chaining

registerTypeback to summary
public ResourceHints registerType(Class<?> type)

Register that the bytecode of the specified type should be made available at runtime.

Parameters
type:Class<?>

the type to include

Returns:ResourceHints

this, to facilitate method chaining

resourceBundleHintsback to summary
public Stream<ResourceBundleHint> resourceBundleHints()

Return the resource bundles that should be made available at runtime.

Returns:Stream<ResourceBundleHint>

a stream of ResourceBundleHint

resourcePatternHintsback to summary
public Stream<ResourcePatternHints> resourcePatternHints()

Return the resources that should be made available at runtime.

Returns:Stream<ResourcePatternHints>

a stream of ResourcePatternHints

toIncludePatternback to summary
private String toIncludePattern(TypeReference type)
typesPatternResourceHintback to summary
private ResourcePatternHints typesPatternResourceHint()