Remove `throws IOException` from DefaultGenerationContext.writeGeneratedContent()
The `throws` declaration is unnecessary since writeGeneratedContent() will never throw an IOException.
This commit is contained in:
parent
a466179bc8
commit
0944c9a99c
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package org.springframework.aot.generate;
|
package org.springframework.aot.generate;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
@ -27,9 +26,9 @@ import org.springframework.util.Assert;
|
||||||
/**
|
/**
|
||||||
* Default {@link GenerationContext} implementation.
|
* Default {@link GenerationContext} implementation.
|
||||||
*
|
*
|
||||||
* <p>Generated classes are flushed out using {@link #writeGeneratedContent()}
|
* <p>Generated classes can be flushed out using {@link #writeGeneratedContent()}
|
||||||
* and should be called once the generation process using this instance has
|
* which should be called only once after the generation process using this instance
|
||||||
* completed.
|
* has completed.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
|
@ -108,7 +107,7 @@ public class DefaultGenerationContext implements GenerationContext {
|
||||||
/**
|
/**
|
||||||
* Write any generated content out to the generated files.
|
* Write any generated content out to the generated files.
|
||||||
*/
|
*/
|
||||||
public void writeGeneratedContent() throws IOException {
|
public void writeGeneratedContent() {
|
||||||
this.generatedClasses.writeTo(this.generatedFiles);
|
this.generatedClasses.writeTo(this.generatedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,10 @@ import org.springframework.lang.Nullable;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A managed collection of generated classes. This class is stateful so the
|
* A managed collection of generated classes.
|
||||||
* same instance should be used for all class generation.
|
*
|
||||||
|
* <p>This class is stateful, so the same instance should be used for all class
|
||||||
|
* generation.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
|
@ -157,7 +159,7 @@ public class GeneratedClasses {
|
||||||
* @param generatedFiles where to write the generated classes
|
* @param generatedFiles where to write the generated classes
|
||||||
* @throws IOException on IO error
|
* @throws IOException on IO error
|
||||||
*/
|
*/
|
||||||
void writeTo(GeneratedFiles generatedFiles) throws IOException {
|
void writeTo(GeneratedFiles generatedFiles) {
|
||||||
Assert.notNull(generatedFiles, "'generatedFiles' must not be null");
|
Assert.notNull(generatedFiles, "'generatedFiles' must not be null");
|
||||||
List<GeneratedClass> generatedClasses = new ArrayList<>(this.classes);
|
List<GeneratedClass> generatedClasses = new ArrayList<>(this.classes);
|
||||||
generatedClasses.sort(Comparator.comparing(GeneratedClass::getName));
|
generatedClasses.sort(Comparator.comparing(GeneratedClass::getName));
|
||||||
|
@ -172,7 +174,6 @@ public class GeneratedClasses {
|
||||||
}
|
}
|
||||||
|
|
||||||
private record Owner(String featureNamePrefix, String featureName, @Nullable Class<?> target) {
|
private record Owner(String featureNamePrefix, String featureName, @Nullable Class<?> target) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
|
|
||||||
package org.springframework.core.testfixture.aot.generate;
|
package org.springframework.core.testfixture.aot.generate;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.UncheckedIOException;
|
|
||||||
|
|
||||||
import org.springframework.aot.generate.ClassNameGenerator;
|
import org.springframework.aot.generate.ClassNameGenerator;
|
||||||
import org.springframework.aot.generate.DefaultGenerationContext;
|
import org.springframework.aot.generate.DefaultGenerationContext;
|
||||||
import org.springframework.aot.generate.GenerationContext;
|
import org.springframework.aot.generate.GenerationContext;
|
||||||
|
@ -26,9 +23,7 @@ import org.springframework.aot.generate.InMemoryGeneratedFiles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link GenerationContext} test implementation that uses
|
* {@link GenerationContext} test implementation that uses
|
||||||
* {@link InMemoryGeneratedFiles} by default, with a convenient override of
|
* {@link InMemoryGeneratedFiles} by default.
|
||||||
* {@link #writeGeneratedContent()} that throws {@link UncheckedIOException}
|
|
||||||
* instead of {@link IOException}.
|
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
|
@ -75,14 +70,4 @@ public class TestGenerationContext extends DefaultGenerationContext {
|
||||||
return (InMemoryGeneratedFiles) super.getGeneratedFiles();
|
return (InMemoryGeneratedFiles) super.getGeneratedFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeGeneratedContent() {
|
|
||||||
try {
|
|
||||||
super.writeGeneratedContent();
|
|
||||||
}
|
|
||||||
catch (IOException ex) {
|
|
||||||
throw new UncheckedIOException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,6 @@
|
||||||
|
|
||||||
package org.springframework.test.aot.generate;
|
package org.springframework.test.aot.generate;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.UncheckedIOException;
|
|
||||||
|
|
||||||
import org.springframework.aot.generate.ClassNameGenerator;
|
import org.springframework.aot.generate.ClassNameGenerator;
|
||||||
import org.springframework.aot.generate.DefaultGenerationContext;
|
import org.springframework.aot.generate.DefaultGenerationContext;
|
||||||
import org.springframework.aot.generate.GenerationContext;
|
import org.springframework.aot.generate.GenerationContext;
|
||||||
|
@ -26,9 +23,7 @@ import org.springframework.aot.generate.InMemoryGeneratedFiles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link GenerationContext} test implementation that uses
|
* {@link GenerationContext} test implementation that uses
|
||||||
* {@link InMemoryGeneratedFiles} by default, with a convenient override of
|
* {@link InMemoryGeneratedFiles} by default.
|
||||||
* {@link #writeGeneratedContent()} that throws {@link UncheckedIOException}
|
|
||||||
* instead of {@link IOException}.
|
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @author Sam Brannen
|
* @author Sam Brannen
|
||||||
|
@ -68,14 +63,4 @@ public class TestGenerationContext extends DefaultGenerationContext {
|
||||||
return (InMemoryGeneratedFiles) super.getGeneratedFiles();
|
return (InMemoryGeneratedFiles) super.getGeneratedFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeGeneratedContent() {
|
|
||||||
try {
|
|
||||||
super.writeGeneratedContent();
|
|
||||||
}
|
|
||||||
catch (IOException ex) {
|
|
||||||
throw new UncheckedIOException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue