Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Fixes suggested by FindBugs.

Authordjarvis <email>
Date2016-12-15 22:23:04 GMT-0800
Commit0fe03b44fbea532fad2b30a1b67e80f63d160f4a
Parent9360d6b
Delta20 lines added, 10 lines removed, 10-line increase
src/main/java/com/scrivenvar/test/TestDefinitionPane.java
test( pane, "c.protagonist", "protagonist" );
- System.exit( 0 );
+ throw new RuntimeException( "Complete" );
}
src/main/java/com/scrivenvar/test/TestHarness.java
protected InputStream asStream( String resource ) {
- return getClass().getResourceAsStream( resource );
+ return TestHarness.class.getResourceAsStream( resource );
}
}
src/main/java/com/scrivenvar/test/TestVariableNameProcessor.java
long duration = System.nanoTime();
-
- // TODO: Test replaceEach (with intercoluated variables) and replaceEachRepeatedly
- // (without intercoluation).
- final String result = testBorAhoCorasick( text, definitions );
-
+ String result = testBorAhoCorasick( text, definitions );
duration = System.nanoTime() - duration;
+ show( result );
+ System.out.println( elapsed( duration ) );
+ duration = System.nanoTime();
+ result = testStringUtils( text, definitions );
+ duration = System.nanoTime() - duration;
show( result );
System.out.println( elapsed( duration ) );
- System.exit( 0 );
+ throw new RuntimeException( "Complete" );
}
private void show( final String s ) {
if( DEBUG ) {
- System.out.printf( "%s\n\n", s );
+ System.out.printf( "%s%n%n", s );
}
}
for( final TreeItem<String> child : parent.getChildren() ) {
if( child.isLeaf() ) {
- final String key = asDefinition( ((VariableTreeItem<String>)child).toPath() );
+ final VariableTreeItem<String> item;
+
+ if( child instanceof VariableTreeItem ) {
+ item = ((VariableTreeItem<String>)child);
+ } else {
+ throw new IllegalArgumentException(
+ "Child must be subclass of VariableTreeItem: " + child );
+ }
+
+ final String key = asDefinition( item.toPath() );
final String value = child.getValue();