Skip to content

Commit c60f69d

Browse files
committed
metafacture-flux/ (main): Fix Checkstyle violations.
1 parent 7e744c7 commit c60f69d

File tree

9 files changed

+85
-61
lines changed

9 files changed

+85
-61
lines changed

config/checkstyle/checkstyle.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"https://checkstyle.org/dtds/configuration_1_3.dtd">
55
<module name="Checker">
66
<module name="SuppressWarningsFilter" />
7+
<module name="SuppressionSingleFilter">
8+
<property name="checks" value=".*"/>
9+
<property name="files" value="generated-src"/>
10+
</module>
711
<module name="TreeWalker">
812
<module name="AbstractClassName"/>
913
<module name="AnnotationUseStyle"/>

metafacture-flux/src/main/java/org/metafacture/flux/FluxCompiler.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,22 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.flux;
1718

18-
import java.io.IOException;
19-
import java.io.InputStream;
20-
import java.util.Map;
19+
import org.metafacture.flux.parser.FlowBuilder;
20+
import org.metafacture.flux.parser.FluxLexer;
21+
import org.metafacture.flux.parser.FluxParser;
22+
import org.metafacture.flux.parser.FluxProgramm;
2123

2224
import org.antlr.runtime.ANTLRInputStream;
2325
import org.antlr.runtime.CommonTokenStream;
2426
import org.antlr.runtime.RecognitionException;
2527
import org.antlr.runtime.tree.CommonTreeNodeStream;
26-
import org.metafacture.flux.parser.FlowBuilder;
27-
import org.metafacture.flux.parser.FluxLexer;
28-
import org.metafacture.flux.parser.FluxParser;
29-
import org.metafacture.flux.parser.FluxProgramm;
28+
29+
import java.io.IOException;
30+
import java.io.InputStream;
31+
import java.util.Map;
3032

3133
/**
3234
* Creates a flow based on a flux script.
@@ -38,7 +40,7 @@ private FluxCompiler() {
3840
// no instances
3941
}
4042

41-
public static FluxProgramm compile(final InputStream flux, final Map<String,String> vars ) throws RecognitionException, IOException{
43+
public static FluxProgramm compile(final InputStream flux, final Map<String, String> vars) throws RecognitionException, IOException {
4244
return compileFlow(compileAst(flux), vars);
4345
}
4446

metafacture-flux/src/main/java/org/metafacture/flux/FluxParseException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.flux;
1718

1819
import org.metafacture.framework.MetafactureException;

metafacture-flux/src/main/java/org/metafacture/flux/HelpPrinter.java

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.flux;
1718

19+
import org.metafacture.commons.ResourceUtil;
20+
import org.metafacture.commons.reflection.ObjectFactory;
21+
import org.metafacture.framework.MetafactureException;
22+
import org.metafacture.framework.annotations.Description;
23+
import org.metafacture.framework.annotations.In;
24+
import org.metafacture.framework.annotations.Out;
25+
import org.metafacture.framework.annotations.ReturnsAvailableArguments;
26+
1827
import java.io.IOException;
1928
import java.io.PrintStream;
2029
import java.lang.reflect.InvocationTargetException;
@@ -24,16 +33,8 @@
2433
import java.util.Collection;
2534
import java.util.Collections;
2635
import java.util.List;
27-
import java.util.Map;
2836
import java.util.Map.Entry;
29-
30-
import org.metafacture.commons.ResourceUtil;
31-
import org.metafacture.commons.reflection.ObjectFactory;
32-
import org.metafacture.framework.MetafactureException;
33-
import org.metafacture.framework.annotations.Description;
34-
import org.metafacture.framework.annotations.In;
35-
import org.metafacture.framework.annotations.Out;
36-
import org.metafacture.framework.annotations.ReturnsAvailableArguments;
37+
import java.util.Map;
3738

3839
/**
3940
* prints Flux help for a given {@link ObjectFactory}
@@ -58,28 +59,26 @@ public static void print(final ObjectFactory<?> factory,
5859
final List<String> keyWords = new ArrayList<String>();
5960
keyWords.addAll(factory.keySet());
6061
Collections.sort(keyWords);
61-
for (String name : keyWords) {
62+
for (final String name : keyWords) {
6263
describe(name, factory, out);
6364
}
6465
}
6566

6667
private static String getVersionInfo() {
6768
try {
6869
return ResourceUtil.loadProperties("build.properties").toString();
69-
} catch (IOException e) {
70+
}
71+
catch (final IOException e) {
7072
throw new MetafactureException("Failed to load build infos", e);
7173
}
7274
}
7375

74-
private static <T> void describe(String name, ObjectFactory<T> factory,
75-
PrintStream out) {
76+
private static <T> void describe(final String name, final ObjectFactory<T> factory, final PrintStream out) {
7677
final Class<? extends T> moduleClass = factory.get(name).getPlainClass();
7778
final Description desc = moduleClass.getAnnotation(Description.class);
7879

7980
out.println(name);
80-
name.chars().forEach(c-> {
81-
out.print("-");
82-
});
81+
name.chars().forEach(c -> out.print("-"));
8382
out.println();
8483

8584
if (desc != null) {
@@ -95,13 +94,14 @@ private static <T> void describe(String name, ObjectFactory<T> factory,
9594
if (!attributes.isEmpty()) {
9695
out.print("- options:\t");
9796
final StringBuilder builder = new StringBuilder();
98-
for (Entry<String, Class<?>> entry : attributes.entrySet()) {
97+
for (final Entry<String, Class<?>> entry : attributes.entrySet()) {
9998
if (entry.getValue().isEnum()) {
10099
builder.append(entry.getKey())
101100
.append(" ")
102101
.append(Arrays.asList(entry.getValue().getEnumConstants()))
103102
.append(", ");
104-
} else {
103+
}
104+
else {
105105
builder.append(entry.getKey())
106106
.append(" (")
107107
.append(entry.getValue().getSimpleName())
@@ -128,14 +128,13 @@ private static <T> void describe(String name, ObjectFactory<T> factory,
128128
}
129129

130130
@SuppressWarnings("unchecked")
131-
private static Collection<String> getAvailableArguments(
132-
Class<?> moduleClass) {
133-
for (Method method : moduleClass.getMethods()) {
131+
private static Collection<String> getAvailableArguments(final Class<?> moduleClass) {
132+
for (final Method method : moduleClass.getMethods()) {
134133
if (method.getAnnotation(ReturnsAvailableArguments.class) != null) {
135134
try {
136135
return (Collection<String>) method.invoke(moduleClass);
137-
} catch (IllegalAccessException | InvocationTargetException |
138-
IllegalArgumentException e) {
136+
}
137+
catch (final IllegalAccessException | InvocationTargetException | IllegalArgumentException e) {
139138
// silently ignore
140139
}
141140
}

metafacture-flux/src/main/java/org/metafacture/flux/parser/Flow.java

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package org.metafacture.flux.parser;
1716

18-
import java.util.ArrayList;
19-
import java.util.Deque;
20-
import java.util.LinkedList;
21-
import java.util.List;
17+
package org.metafacture.flux.parser;
2218

2319
import org.metafacture.flux.FluxParseException;
2420
import org.metafacture.framework.LifeCycle;
@@ -28,6 +24,10 @@
2824
import org.metafacture.framework.Tee;
2925
import org.metafacture.io.StdInOpener;
3026

27+
import java.util.ArrayList;
28+
import java.util.Deque;
29+
import java.util.LinkedList;
30+
import java.util.List;
3131

3232
/**
3333
* @author Markus Michael Geipel
@@ -42,9 +42,12 @@ final class Flow {
4242
private ObjectReceiver<? extends Object> start;
4343
private boolean joinLooseEnds;
4444

45-
@SuppressWarnings({ "unchecked", "rawtypes" })
45+
Flow() {
46+
}
47+
48+
@SuppressWarnings("unchecked")
4649
public void addElement(final Receiver nextElement) {
47-
if(element==null){
50+
if (element == null) {
4851
setStart((ObjectReceiver<? extends Object>) nextElement);
4952
return;
5053
}
@@ -55,19 +58,23 @@ public void addElement(final Receiver nextElement) {
5558
for (final LifeCycle looseEnd : looseEndsStack.pop()) {
5659
if (looseEnd instanceof Tee) {
5760
((Tee) looseEnd).addReceiver(nextElement);
58-
} else {
61+
}
62+
else {
5963
((Sender) looseEnd).setReceiver(nextElement);
6064
}
6165
}
6266
joinLooseEnds = false;
63-
} else {
67+
}
68+
else {
6469
if (sender instanceof Tee) {
6570
((Tee) sender).addReceiver(nextElement);
66-
} else {
71+
}
72+
else {
6773
sender.setReceiver(nextElement);
6874
}
6975
}
70-
} else {
76+
}
77+
else {
7178
throw new FluxParseException(element.getClass().getCanonicalName() + "is not a sender");
7279
}
7380
element = nextElement;
@@ -78,7 +85,8 @@ public void startTee() {
7885
final Tee<?> tee = (Tee<?>) element;
7986
teeStack.push(tee);
8087
looseEndsStack.push(new ArrayList<LifeCycle>());
81-
} else {
88+
}
89+
else {
8290
throw new FluxParseException("Flow cannot be split without a tee-element.");
8391
}
8492
}
@@ -93,7 +101,7 @@ public void endSubFlow() {
93101
element = teeStack.peek();
94102
}
95103

96-
private void setStart(final ObjectReceiver<? extends Object> start){
104+
private void setStart(final ObjectReceiver<? extends Object> start) {
97105
this.start = start;
98106
element = start;
99107
}

metafacture-flux/src/main/java/org/metafacture/flux/parser/FluxProgramm.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.flux.parser;
1718

19+
import org.metafacture.commons.ResourceUtil;
20+
import org.metafacture.commons.reflection.ConfigurableClass;
21+
import org.metafacture.commons.reflection.ObjectFactory;
22+
import org.metafacture.commons.reflection.ReflectionUtil;
23+
import org.metafacture.flux.FluxParseException;
24+
import org.metafacture.flux.HelpPrinter;
25+
import org.metafacture.framework.Receiver;
26+
1827
import java.io.IOException;
1928
import java.io.PrintStream;
2029
import java.net.URL;
@@ -27,14 +36,6 @@
2736
import java.util.Map;
2837
import java.util.Set;
2938

30-
import org.metafacture.commons.ResourceUtil;
31-
import org.metafacture.commons.reflection.ConfigurableClass;
32-
import org.metafacture.commons.reflection.ObjectFactory;
33-
import org.metafacture.commons.reflection.ReflectionUtil;
34-
import org.metafacture.flux.FluxParseException;
35-
import org.metafacture.flux.HelpPrinter;
36-
import org.metafacture.framework.Receiver;
37-
3839
/**
3940
* @author Markus Michael Geipel
4041
*
@@ -52,7 +53,8 @@ public final class FluxProgramm {
5253
final URL url = enumeration.nextElement();
5354
COMMAND_FACTORY.loadClassesFromMap(ResourceUtil.loadProperties(url), Receiver.class);
5455
}
55-
} catch (final IOException e) {
56+
}
57+
catch (final IOException e) {
5658
throw new FluxParseException("unable to load properties.", e);
5759
}
5860
}
@@ -62,14 +64,18 @@ public final class FluxProgramm {
6264
private final Map<String, Wormhole> wormholeNameMapping = new HashMap<String, Wormhole>();
6365
private final Map<Flow, Wormhole> wormholeInFlowMapping = new Hashtable<Flow, Wormhole>();
6466

67+
public FluxProgramm() {
68+
}
69+
6570
private static Receiver createElement(final String name, final Map<String, String> namedArgs,
6671
final List<Object> cArgs) {
6772

6873
final Receiver newElement;
6974
if (COMMAND_FACTORY.containsKey(name)) {
7075
newElement = COMMAND_FACTORY.newInstance(name, namedArgs, cArgs.toArray());
7176

72-
} else {
77+
}
78+
else {
7379
final ConfigurableClass<? extends Receiver> elementClass =
7480
ReflectionUtil.loadClass(name, Receiver.class);
7581
newElement = elementClass.newInstance(namedArgs, cArgs.toArray());
@@ -156,7 +162,8 @@ public void start() {
156162
flow.start();
157163
if (!wormholeInFlowMapping.containsKey(flow)) {
158164
flow.close();
159-
} else {
165+
}
166+
else {
160167
wormholeInFlowMapping.get(flow).finished(flow);
161168
}
162169
}
@@ -172,7 +179,7 @@ private static final class Wormhole {
172179
private Flow out;
173180
private final String name;
174181

175-
public Wormhole(final String name) {
182+
Wormhole(final String name) {
176183
this.name = name;
177184
}
178185

metafacture-flux/src/main/java/org/metafacture/flux/parser/StringSender.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.flux.parser;
1718

1819
import org.metafacture.framework.ObjectReceiver;
1920
import org.metafacture.framework.helpers.DefaultObjectPipe;
2021

21-
2222
/**
2323
* Helper class to start a pipe with a {@link String}
2424
*
2525
* @author Markus Michael Geipel
2626
*/
27-
public final class StringSender extends DefaultObjectPipe<Object, ObjectReceiver<String>>{
27+
public final class StringSender extends DefaultObjectPipe<Object, ObjectReceiver<String>> {
2828

2929
private final String string;
3030

@@ -34,9 +34,10 @@ public StringSender(final String string) {
3434

3535
@Override
3636
public void process(final Object notUsed) {
37-
if(notUsed==null){
38-
getReceiver().process(string);
39-
}else{
37+
if (notUsed == null) {
38+
getReceiver().process(string);
39+
}
40+
else {
4041
throw new IllegalArgumentException("Parameter not used. Must be null");
4142
}
4243
}

metafacture-flux/src/test/java/org/metafacture/flux/FluxGrammarTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.flux;
1718

1819
import static java.util.Collections.emptyMap;

metafacture-flux/src/test/java/org/metafacture/flux/FluxProgrammTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.metafacture.flux;
1718

1819
import java.io.IOException;

0 commit comments

Comments
 (0)