Fix minor warnings:

remove unnecessary generic type for collections,
replace Charset.forName on StandartCharset
This commit is contained in:
Andrei Arlou 2019-08-12 22:20:53 +03:00 committed by Filip Hrisafov
parent dbe761e738
commit 59a5182dab
4 changed files with 13 additions and 16 deletions

View File

@ -111,7 +111,7 @@ public class ProcessorSuiteRunner extends ParentRunner<ProcessorTestCase> {
private List<ProcessorTestCase> initializeTestCases(ProcessorSuite suite, private List<ProcessorTestCase> initializeTestCases(ProcessorSuite suite,
Constructor<? extends CommandLineEnhancer> cliEnhancerConstructor) { Constructor<? extends CommandLineEnhancer> cliEnhancerConstructor) {
List<ProcessorType> types = new ArrayList<ProcessorType>(); List<ProcessorType> types = new ArrayList<>();
for ( ProcessorType compiler : suite.processorTypes() ) { for ( ProcessorType compiler : suite.processorTypes() ) {
if ( compiler.getIncluded().length > 0 ) { if ( compiler.getIncluded().length > 0 ) {
@ -190,7 +190,7 @@ public class ProcessorSuiteRunner extends ParentRunner<ProcessorTestCase> {
verifier = new Verifier( destination.getCanonicalPath() ); verifier = new Verifier( destination.getCanonicalPath() );
} }
List<String> goals = new ArrayList<String>( 3 ); List<String> goals = new ArrayList<>( 3 );
goals.add( "clean" ); goals.add( "clean" );

View File

@ -51,7 +51,7 @@ public abstract class HelperMethod implements Method {
* @return the types used by this method for which import statements need to be generated * @return the types used by this method for which import statements need to be generated
*/ */
public Set<Type> getImportTypes() { public Set<Type> getImportTypes() {
return Collections.<Type>emptySet(); return Collections.emptySet();
} }
/** /**

View File

@ -153,12 +153,12 @@ public class Strings {
} }
int c = 1; int c = 1;
String seperator = Character.isDigit( name.charAt( name.length() - 1 ) ) ? "_" : ""; String separator = Character.isDigit( name.charAt( name.length() - 1 ) ) ? "_" : "";
while ( conflictingNames.contains( name + seperator + c ) ) { while ( conflictingNames.contains( name + separator + c ) ) {
c++; c++;
} }
return name + seperator + c; return name + separator + c;
} }
/** /**

View File

@ -12,7 +12,7 @@ import java.io.InputStreamReader;
import java.io.Reader; import java.io.Reader;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.nio.charset.Charset; import java.nio.charset.StandardCharsets;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -62,16 +62,13 @@ public class ModelWriter {
} }
public void writeModel(FileObject sourceFile, Writable model) { public void writeModel(FileObject sourceFile, Writable model) {
try { try ( BufferedWriter writer = new BufferedWriter( new IndentationCorrectingWriter( sourceFile.openWriter() ))) {
BufferedWriter writer = new BufferedWriter( new IndentationCorrectingWriter( sourceFile.openWriter() ) );
Map<Class<?>, Object> values = new HashMap<>(); Map<Class<?>, Object> values = new HashMap<>();
values.put( Configuration.class, CONFIGURATION ); values.put( Configuration.class, CONFIGURATION );
model.write( new DefaultModelElementWriterContext( values ), writer ); model.write( new DefaultModelElementWriterContext( values ), writer );
writer.flush(); writer.flush();
writer.close();
} }
catch ( RuntimeException e ) { catch ( RuntimeException e ) {
throw e; throw e;
@ -100,7 +97,7 @@ public class ModelWriter {
InputStream is = connection.getInputStream(); InputStream is = connection.getInputStream();
return new InputStreamReader( is, Charset.forName( "UTF-8" ) ); return new InputStreamReader( is, StandardCharsets.UTF_8 );
} }
@Override @Override