java.lang.Object
org.springframework.aot.test.generator.file.DynamicFile
org.springframework.aot.test.generator.file.SourceFile
All Implemented Interfaces:
org.assertj.core.api.AssertProvider<SourceFileAssert>

public final class SourceFile extends DynamicFile implements org.assertj.core.api.AssertProvider<SourceFileAssert>
DynamicFile that holds Java source code and provides SourceFileAssert support. Usually created from an AOT generated type, for example:
 SourceFile.of(generatedFile::writeTo)
 
Since:
6.0
Author:
Phillip Webb
  • Method Details

    • of

      public static SourceFile of(CharSequence charSequence)
      Factory method to create a new SourceFile from the given CharSequence.
      Parameters:
      charSequence - a file containing the source contents
      Returns:
      a SourceFile instance
    • of

      public static SourceFile of(@Nullable String path, CharSequence charSequence)
      Factory method to create a new SourceFile from the given CharSequence.
      Parameters:
      path - the relative path of the file or null to have the path deduced
      charSequence - a file containing the source contents
      Returns:
      a SourceFile instance
    • of

      public static SourceFile of(WritableContent writableContent)
      Factory method to create a new SourceFile from the given WritableContent.
      Parameters:
      writableContent - the content to write to the file
      Returns:
      a SourceFile instance
    • of

      public static SourceFile of(@Nullable String path, WritableContent writableContent)
      Factory method to create a new SourceFile from the given WritableContent.
      Parameters:
      path - the relative path of the file or null to have the path deduced
      writableContent - the content to write to the file
      Returns:
      a SourceFile instance
    • getTarget

      @Nullable public Class<?> getTarget()
      Return the target class for this source file or null. The target class can be used if private lookup access is required.
      Returns:
      the target class
    • getClassName

      public String getClassName()
    • assertThat

      @Deprecated public SourceFileAssert assertThat()
      Deprecated.
      use assertThat(sourceFile) rather than calling this method directly.
      AssertJ assertThat support.
      Specified by:
      assertThat in interface org.assertj.core.api.AssertProvider<SourceFileAssert>