39
39
* @see InMemoryGeneratedFiles
40
40
* @see FileSystemGeneratedFiles
41
41
*/
42
- public abstract class GeneratedFiles {
42
+ public interface GeneratedFiles {
43
43
44
44
/**
45
45
* Add a generated {@link Kind#SOURCE source file} with content from the
46
46
* given {@link JavaFile}.
47
47
* @param javaFile the java file to add
48
48
*/
49
- public void addSourceFile (JavaFile javaFile ) {
49
+ default void addSourceFile (JavaFile javaFile ) {
50
50
validatePackage (javaFile .packageName , javaFile .typeSpec .name );
51
51
String className = javaFile .packageName + "." + javaFile .typeSpec .name ;
52
52
addSourceFile (className , javaFile ::writeTo );
@@ -59,7 +59,7 @@ public void addSourceFile(JavaFile javaFile) {
59
59
* of the file
60
60
* @param content the contents of the file
61
61
*/
62
- public void addSourceFile (String className , CharSequence content ) {
62
+ default void addSourceFile (String className , CharSequence content ) {
63
63
addSourceFile (className , appendable -> appendable .append (content ));
64
64
}
65
65
@@ -71,7 +71,7 @@ public void addSourceFile(String className, CharSequence content) {
71
71
* @param content a {@link ThrowingConsumer} that accepts an
72
72
* {@link Appendable} which will receive the file contents
73
73
*/
74
- public void addSourceFile (String className , ThrowingConsumer <Appendable > content ) {
74
+ default void addSourceFile (String className , ThrowingConsumer <Appendable > content ) {
75
75
addFile (Kind .SOURCE , getClassNamePath (className ), content );
76
76
}
77
77
@@ -83,7 +83,7 @@ public void addSourceFile(String className, ThrowingConsumer<Appendable> content
83
83
* @param content an {@link InputStreamSource} that will provide an input
84
84
* stream containing the file contents
85
85
*/
86
- public void addSourceFile (String className , InputStreamSource content ) {
86
+ default void addSourceFile (String className , InputStreamSource content ) {
87
87
addFile (Kind .SOURCE , getClassNamePath (className ), content );
88
88
}
89
89
@@ -93,7 +93,7 @@ public void addSourceFile(String className, InputStreamSource content) {
93
93
* @param path the relative path of the file
94
94
* @param content the contents of the file
95
95
*/
96
- public void addResourceFile (String path , CharSequence content ) {
96
+ default void addResourceFile (String path , CharSequence content ) {
97
97
addResourceFile (path , appendable -> appendable .append (content ));
98
98
}
99
99
@@ -104,7 +104,7 @@ public void addResourceFile(String path, CharSequence content) {
104
104
* @param content a {@link ThrowingConsumer} that accepts an
105
105
* {@link Appendable} which will receive the file contents
106
106
*/
107
- public void addResourceFile (String path , ThrowingConsumer <Appendable > content ) {
107
+ default void addResourceFile (String path , ThrowingConsumer <Appendable > content ) {
108
108
addFile (Kind .RESOURCE , path , content );
109
109
}
110
110
@@ -115,7 +115,7 @@ public void addResourceFile(String path, ThrowingConsumer<Appendable> content) {
115
115
* @param content an {@link InputStreamSource} that will provide an input
116
116
* stream containing the file contents
117
117
*/
118
- public void addResourceFile (String path , InputStreamSource content ) {
118
+ default void addResourceFile (String path , InputStreamSource content ) {
119
119
addFile (Kind .RESOURCE , path , content );
120
120
}
121
121
@@ -126,7 +126,7 @@ public void addResourceFile(String path, InputStreamSource content) {
126
126
* @param content an {@link InputStreamSource} that will provide an input
127
127
* stream containing the file contents
128
128
*/
129
- public void addClassFile (String path , InputStreamSource content ) {
129
+ default void addClassFile (String path , InputStreamSource content ) {
130
130
addFile (Kind .CLASS , path , content );
131
131
}
132
132
@@ -137,7 +137,7 @@ public void addClassFile(String path, InputStreamSource content) {
137
137
* @param path the relative path of the file
138
138
* @param content the contents of the file
139
139
*/
140
- public void addFile (Kind kind , String path , CharSequence content ) {
140
+ default void addFile (Kind kind , String path , CharSequence content ) {
141
141
addFile (kind , path , appendable -> appendable .append (content ));
142
142
}
143
143
@@ -149,7 +149,7 @@ public void addFile(Kind kind, String path, CharSequence content) {
149
149
* @param content a {@link ThrowingConsumer} that accepts an
150
150
* {@link Appendable} which will receive the file contents
151
151
*/
152
- public void addFile (Kind kind , String path , ThrowingConsumer <Appendable > content ) {
152
+ default void addFile (Kind kind , String path , ThrowingConsumer <Appendable > content ) {
153
153
Assert .notNull (content , "'content' must not be null" );
154
154
addFile (kind , path , new AppendableConsumerInputStreamSource (content ));
155
155
}
@@ -162,7 +162,7 @@ public void addFile(Kind kind, String path, ThrowingConsumer<Appendable> content
162
162
* @param content an {@link InputStreamSource} that will provide an input
163
163
* stream containing the file contents
164
164
*/
165
- public void addFile (Kind kind , String path , InputStreamSource content ) {
165
+ default void addFile (Kind kind , String path , InputStreamSource content ) {
166
166
Assert .notNull (kind , "'kind' must not be null" );
167
167
Assert .hasLength (path , "'path' must not be empty" );
168
168
Assert .notNull (content , "'content' must not be null" );
@@ -179,7 +179,7 @@ public void addFile(Kind kind, String path, InputStreamSource content) {
179
179
* @param handler a consumer of a {@link FileHandler} for the file
180
180
* @since 6.2
181
181
*/
182
- public abstract void handleFile (Kind kind , String path , ThrowingConsumer <FileHandler > handler );
182
+ void handleFile (Kind kind , String path , ThrowingConsumer <FileHandler > handler );
183
183
184
184
private static String getClassNamePath (String className ) {
185
185
Assert .hasLength (className , "'className' must not be empty" );
@@ -214,7 +214,7 @@ private static boolean isJavaIdentifier(String className) {
214
214
/**
215
215
* The various kinds of generated files that are supported.
216
216
*/
217
- public enum Kind {
217
+ enum Kind {
218
218
219
219
/**
220
220
* A source file containing Java code that should be compiled.
@@ -241,7 +241,7 @@ public enum Kind {
241
241
*
242
242
* @since 6.2
243
243
*/
244
- public abstract static class FileHandler {
244
+ abstract class FileHandler {
245
245
246
246
private final boolean exists ;
247
247
0 commit comments