Class GeneratedResource

java.lang.Object
org.springframework.aot.generate.GeneratedResource

public final class GeneratedResource extends Object
A single generated resource.
Since:
7.1
Author:
Stephane Nicoll
See Also:
  • Method Details

    • getPath

      public String getPath()
      Return the absolute path of this resource on the classpath.

      The path returned by this method does not have a leading slash and is suitable for generated code that use ClassLoader.getResource(String).

      Returns:
      the path of this resource on the classpath
      See Also:
    • hasContent

      public boolean hasContent()
      Whether this instance has content associated to it. Instances that do not have content are not contributed to GeneratedFiles.
      Returns:
      true if this instance has content
      See Also:
    • handle

      public void handle(Consumer<GeneratedResource.Content> content)
      Handle this instance, using the provided GeneratedResource.Content.

      create only allows a single attempt to create the content of a generated resource. If several rounds of AOT processing may touch the same unique path, use createOrValidate instead, which creates the content on the first call and validates it against subsequent calls.

      Parameters:
      content - the content to use
    • toString

      public String toString()
      Overrides:
      toString in class Object