Class JavaFileObjects
java.lang.Object
io.micronaut.annotation.processing.test.JavaFileObjects
A utility class for creating
JavaFileObject instances.- Author:
- Gregory Kick
-
Method Summary
Modifier and TypeMethodDescriptionstatic JavaFileObjectforSourceLines(String fullyQualifiedName, Iterable<String> lines) An overload of#forSourceLinesthat takes anIterable<String>.static JavaFileObjectforSourceLines(String fullyQualifiedName, String... lines) Behaves exactly likeforSourceString(String, String), but joins lines so that multi-line source strings may omit the newline characters.static JavaFileObjectforSourceString(String fullyQualifiedName, String source) Creates aJavaFileObjectwith a path corresponding to thefullyQualifiedNamecontaining the givesource.
-
Method Details
-
forSourceString
Creates aJavaFileObjectwith a path corresponding to thefullyQualifiedNamecontaining the givesource. The returned object will always be read-only and have theJavaFileObject.Kind.SOURCEkind.Note that this method makes no attempt to verify that the name matches the contents of the source and compilation errors may result if they do not match.
- Parameters:
fullyQualifiedName- the fully qualified namesource- The source- Returns:
- the java file object
-
forSourceLines
Behaves exactly likeforSourceString(String, String), but joins lines so that multi-line source strings may omit the newline characters. For example:JavaFileObjects.forSourceLines("example.HelloWorld", "package example;", "", "final class HelloWorld {", " void sayHello() {", " System.out.println(\"hello!\");", " }", "}");- Parameters:
fullyQualifiedName- the fully qualified namelines- The source- Returns:
- The java file object
-
forSourceLines
An overload of#forSourceLinesthat takes anIterable<String>.- Parameters:
fullyQualifiedName- the fully qualified namelines- The source- Returns:
- The java file object
-