From 2f57d06fda6a0ca2f47189c1cc80565b2416dfc6 Mon Sep 17 00:00:00 2001 From: Jens Wille Date: Wed, 29 Jan 2025 14:22:43 +0100 Subject: [PATCH] Add missing Javadoc comments to metafacture-fix methods/constructors. (#577) --- config/checkstyle/checkstyle.xml | 4 +- .../metafacture/metafix/ide/FixIdeModule.java | 5 + .../metafacture/metafix/ide/FixIdeSetup.java | 3 + .../metafacture/metafix/web/FixServlet.java | 3 + .../metafacture/metafix/web/FixWebModule.java | 5 + .../metafacture/metafix/web/FixWebSetup.java | 3 + .../metafix/web/ServerLauncher.java | 5 + .../metafix/AbstractBenchmark.java | 6 + .../metafix/BaselineBenchmark.java | 3 + .../metafix/FixParseBenchmark.java | 6 + .../metafacture/metafix/MetafixBenchmark.java | 3 + .../org/metafacture/metafix/FindFixPaths.java | 7 + .../metafix/FixExecutionException.java | 11 + .../metafix/FixParseException.java | 11 + .../metafix/FixProcessException.java | 11 + .../metafacture/metafix/FixRuntimeModule.java | 8 + .../metafix/FixStandaloneSetup.java | 33 +++ .../org/metafacture/metafix/JsonValue.java | 27 ++ .../org/metafacture/metafix/ListFixPaths.java | 16 ++ .../metafacture/metafix/ListFixValues.java | 5 + .../java/org/metafacture/metafix/Metafix.java | 139 +++++++++- .../java/org/metafacture/metafix/Record.java | 26 +- .../metafix/RecordTransformer.java | 11 + .../java/org/metafacture/metafix/Value.java | 260 +++++++++++++++++- .../metafacture/metafix/api/FixContext.java | 9 + .../metafacture/metafix/api/FixFunction.java | 87 ++++++ .../metafacture/metafix/api/FixPredicate.java | 46 ++++ .../metafix/interpreter/FixInterpreter.java | 9 + .../metafix/jvmmodel/FixJvmModelInferrer.java | 10 + .../metafix/scoping/FixScopeProvider.java | 3 + .../metafix/validation/FixValidator.java | 3 + .../metafix/validation/XtextValidator.java | 24 ++ .../metamorph/collectors/Concat.java | 2 +- 33 files changed, 784 insertions(+), 20 deletions(-) diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 5e9fc72ca..a9ba9998a 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -13,7 +13,7 @@ - + @@ -93,7 +93,7 @@ - + diff --git a/metafix-ide/src/main/java/org/metafacture/metafix/ide/FixIdeModule.java b/metafix-ide/src/main/java/org/metafacture/metafix/ide/FixIdeModule.java index 4b9f47859..911a72408 100644 --- a/metafix-ide/src/main/java/org/metafacture/metafix/ide/FixIdeModule.java +++ b/metafix-ide/src/main/java/org/metafacture/metafix/ide/FixIdeModule.java @@ -4,6 +4,11 @@ * Use this class to register ide components. */ public class FixIdeModule extends AbstractFixIdeModule { + + /** + * Creates an instance of {@link FixIdeModule}. + */ public FixIdeModule() { } + } diff --git a/metafix-ide/src/main/java/org/metafacture/metafix/ide/FixIdeSetup.java b/metafix-ide/src/main/java/org/metafacture/metafix/ide/FixIdeSetup.java index 2dd6f9fca..87576b79c 100644 --- a/metafix-ide/src/main/java/org/metafacture/metafix/ide/FixIdeSetup.java +++ b/metafix-ide/src/main/java/org/metafacture/metafix/ide/FixIdeSetup.java @@ -12,6 +12,9 @@ */ public class FixIdeSetup extends FixStandaloneSetup { + /** + * Creates an instance of {@link FixIdeSetup}. + */ public FixIdeSetup() { } diff --git a/metafix-web/src/main/java/org/metafacture/metafix/web/FixServlet.java b/metafix-web/src/main/java/org/metafacture/metafix/web/FixServlet.java index ae87a658f..a460f3165 100644 --- a/metafix-web/src/main/java/org/metafacture/metafix/web/FixServlet.java +++ b/metafix-web/src/main/java/org/metafacture/metafix/web/FixServlet.java @@ -33,6 +33,9 @@ public class FixServlet extends XtextServlet { private DisposableRegistry disposableRegistry; + /** + * Creates an instance of {@link FixServlet}. + */ public FixServlet() { } diff --git a/metafix-web/src/main/java/org/metafacture/metafix/web/FixWebModule.java b/metafix-web/src/main/java/org/metafacture/metafix/web/FixWebModule.java index ad61024ed..c7ed81c15 100644 --- a/metafix-web/src/main/java/org/metafacture/metafix/web/FixWebModule.java +++ b/metafix-web/src/main/java/org/metafacture/metafix/web/FixWebModule.java @@ -5,6 +5,11 @@ * application. */ public class FixWebModule extends AbstractFixWebModule { + + /** + * Creates an instance of {@link FixWebModule}. + */ public FixWebModule() { } + } diff --git a/metafix-web/src/main/java/org/metafacture/metafix/web/FixWebSetup.java b/metafix-web/src/main/java/org/metafacture/metafix/web/FixWebSetup.java index ad7c397af..2d8f55fdb 100644 --- a/metafix-web/src/main/java/org/metafacture/metafix/web/FixWebSetup.java +++ b/metafix-web/src/main/java/org/metafacture/metafix/web/FixWebSetup.java @@ -13,6 +13,9 @@ */ public class FixWebSetup extends FixStandaloneSetup { + /** + * Creates an instance of {@link FixWebSetup}. + */ public FixWebSetup() { } diff --git a/metafix-web/src/main/java/org/metafacture/metafix/web/ServerLauncher.java b/metafix-web/src/main/java/org/metafacture/metafix/web/ServerLauncher.java index 6b5658a0c..898f7bdba 100644 --- a/metafix-web/src/main/java/org/metafacture/metafix/web/ServerLauncher.java +++ b/metafix-web/src/main/java/org/metafacture/metafix/web/ServerLauncher.java @@ -22,6 +22,11 @@ private ServerLauncher() { throw new IllegalAccessError("Utility class"); } + /** + * Starts an HTTP server for testing the web integration of your DSL. + * + * @param args unused + */ public static void main(final String[] args) { final WebAppContext context = new WebAppContext(); context.setResourceBase("src/main/webapp"); diff --git a/metafix/src/jmh/java/org/metafacture/metafix/AbstractBenchmark.java b/metafix/src/jmh/java/org/metafacture/metafix/AbstractBenchmark.java index 6b65f7099..002ca703a 100644 --- a/metafix/src/jmh/java/org/metafacture/metafix/AbstractBenchmark.java +++ b/metafix/src/jmh/java/org/metafacture/metafix/AbstractBenchmark.java @@ -42,9 +42,15 @@ @State(Scope.Thread) public abstract class AbstractBenchmark { + /** + * Creates an instance of {@link AbstractBenchmark}. + */ public AbstractBenchmark() { } + /** + * Performs the benchmark. + */ @Benchmark public void benchmark() { workload(); diff --git a/metafix/src/jmh/java/org/metafacture/metafix/BaselineBenchmark.java b/metafix/src/jmh/java/org/metafacture/metafix/BaselineBenchmark.java index 6c0313e5a..6031862e1 100644 --- a/metafix/src/jmh/java/org/metafacture/metafix/BaselineBenchmark.java +++ b/metafix/src/jmh/java/org/metafacture/metafix/BaselineBenchmark.java @@ -23,6 +23,9 @@ @OutputTimeUnit(TimeUnit.MICROSECONDS) public class BaselineBenchmark extends AbstractBenchmark { + /** + * Creates an instance of {@link BaselineBenchmark}. + */ public BaselineBenchmark() { } diff --git a/metafix/src/jmh/java/org/metafacture/metafix/FixParseBenchmark.java b/metafix/src/jmh/java/org/metafacture/metafix/FixParseBenchmark.java index c513b70c1..823c9f582 100644 --- a/metafix/src/jmh/java/org/metafacture/metafix/FixParseBenchmark.java +++ b/metafix/src/jmh/java/org/metafacture/metafix/FixParseBenchmark.java @@ -32,9 +32,15 @@ public class FixParseBenchmark extends AbstractBenchmark { }) private String fixDef; + /** + * Creates an instance of {@link FixParseBenchmark}. + */ public FixParseBenchmark() { } + /** + * Performs the setup. + */ @Setup public void setup() { fixFile = String.format(FIXES, fixDef); diff --git a/metafix/src/jmh/java/org/metafacture/metafix/MetafixBenchmark.java b/metafix/src/jmh/java/org/metafacture/metafix/MetafixBenchmark.java index 4f7024c3e..ba6832720 100644 --- a/metafix/src/jmh/java/org/metafacture/metafix/MetafixBenchmark.java +++ b/metafix/src/jmh/java/org/metafacture/metafix/MetafixBenchmark.java @@ -44,6 +44,9 @@ public class MetafixBenchmark extends FixParseBenchmark { // checkstyle-disable- }) private String input; + /** + * Creates an instance of {@link MetafixBenchmark}. + */ public MetafixBenchmark() { } diff --git a/metafix/src/main/java/org/metafacture/metafix/FindFixPaths.java b/metafix/src/main/java/org/metafacture/metafix/FindFixPaths.java index df46d3afc..d0e5d222f 100644 --- a/metafix/src/main/java/org/metafacture/metafix/FindFixPaths.java +++ b/metafix/src/main/java/org/metafacture/metafix/FindFixPaths.java @@ -43,9 +43,15 @@ @FluxCommand("find-fix-paths") public class FindFixPaths extends DefaultStreamPipe> { + private final Metafix fix; private String objectPattern; + /** + * Creates an instance of {@link FindFixPaths}. + * + * @param objectPattern the pattern to match + */ public FindFixPaths(final String objectPattern) { this.objectPattern = objectPattern; try { @@ -103,4 +109,5 @@ protected void onCloseStream() { protected void onResetStream() { fix.resetStream(); } + } diff --git a/metafix/src/main/java/org/metafacture/metafix/FixExecutionException.java b/metafix/src/main/java/org/metafacture/metafix/FixExecutionException.java index bb20f522a..083c514cc 100644 --- a/metafix/src/main/java/org/metafacture/metafix/FixExecutionException.java +++ b/metafix/src/main/java/org/metafacture/metafix/FixExecutionException.java @@ -26,10 +26,21 @@ */ public class FixExecutionException extends MetafactureException { + /** + * Creates an instance of {@link FixExecutionException}. + * + * @param message the exception message + */ public FixExecutionException(final String message) { super(message); } + /** + * Creates an instance of {@link FixExecutionException}. + * + * @param message the exception message + * @param cause the exception cause + */ public FixExecutionException(final String message, final Throwable cause) { super(message, cause); } diff --git a/metafix/src/main/java/org/metafacture/metafix/FixParseException.java b/metafix/src/main/java/org/metafacture/metafix/FixParseException.java index 366a58ff1..bb2f61119 100644 --- a/metafix/src/main/java/org/metafacture/metafix/FixParseException.java +++ b/metafix/src/main/java/org/metafacture/metafix/FixParseException.java @@ -20,10 +20,21 @@ public class FixParseException extends MetafactureException { + /** + * Creates an instance of {@link FixParseException}. + * + * @param message the exception message + */ public FixParseException(final String message) { super(message); } + /** + * Creates an instance of {@link FixParseException}. + * + * @param message the exception message + * @param cause the exception cause + */ public FixParseException(final String message, final Throwable cause) { super(message, cause); } diff --git a/metafix/src/main/java/org/metafacture/metafix/FixProcessException.java b/metafix/src/main/java/org/metafacture/metafix/FixProcessException.java index 849f445c7..6dc783299 100644 --- a/metafix/src/main/java/org/metafacture/metafix/FixProcessException.java +++ b/metafix/src/main/java/org/metafacture/metafix/FixProcessException.java @@ -26,10 +26,21 @@ */ public class FixProcessException extends MetafactureException { + /** + * Creates an instance of {@link FixProcessException}. + * + * @param message the exception message + */ public FixProcessException(final String message) { super(message); } + /** + * Creates an instance of {@link FixProcessException}. + * + * @param message the exception message + * @param cause the exception cause + */ public FixProcessException(final String message, final Throwable cause) { super(message, cause); } diff --git a/metafix/src/main/java/org/metafacture/metafix/FixRuntimeModule.java b/metafix/src/main/java/org/metafacture/metafix/FixRuntimeModule.java index 59aaca061..85df0dfab 100644 --- a/metafix/src/main/java/org/metafacture/metafix/FixRuntimeModule.java +++ b/metafix/src/main/java/org/metafacture/metafix/FixRuntimeModule.java @@ -7,9 +7,17 @@ */ public class FixRuntimeModule extends AbstractFixRuntimeModule { + /** + * Creates an instance of {@link FixRuntimeModule}. + */ public FixRuntimeModule() { } + /** + * Returns the class to bind to. + * + * @return the class + */ public Class bindFixInterpreter() { return FixInterpreter.class; } diff --git a/metafix/src/main/java/org/metafacture/metafix/FixStandaloneSetup.java b/metafix/src/main/java/org/metafacture/metafix/FixStandaloneSetup.java index cbe9b86f5..2b9bdf55b 100644 --- a/metafix/src/main/java/org/metafacture/metafix/FixStandaloneSetup.java +++ b/metafix/src/main/java/org/metafacture/metafix/FixStandaloneSetup.java @@ -16,9 +16,18 @@ */ public class FixStandaloneSetup extends FixStandaloneSetupGenerated { + /** + * Creates an instance of {@link FixStandaloneSetup}. + */ public FixStandaloneSetup() { } + /** + * {@link XtextValidator#validate(String, ISetup) Validates} the Fix file. + * Exits with error code {@code 1} if validation fails. + * + * @param args the pathname of the Fix file to validate + */ public static void main(final String[] args) { if (args != null && args.length == 1) { System.exit(XtextValidator.validate(args[0], new FixStandaloneSetup()) ? 0 : 1); @@ -27,10 +36,26 @@ public static void main(final String[] args) { throw new IllegalArgumentException(String.format("Usage: %s ", FixStandaloneSetup.class.getName())); } + /** + * {@link XtextValidator#getValidatedResource(String, ISetup) Parses and validates} + * the Fix file. + * + * @param path the pathname of the Fix file to parse + * + * @return the Fix instance + */ public static Fix parseFix(final String path) { return (Fix) XtextValidator.getValidatedResource(path, new FixStandaloneSetup()).getContents().get(0); } + /** + * {@link XtextValidator#getValidatedResource(String, ISetup) Parses and validates} + * the Fix definition after storing it in a {@link #absPathToTempFile temporary file}. + * + * @param fixDef the Fix definition to parse + * + * @return the Fix instance + */ public static Fix parseFix(final Reader fixDef) { try { return parseFix(absPathToTempFile(fixDef, ".fix")); @@ -40,6 +65,14 @@ public static Fix parseFix(final Reader fixDef) { } } + /** + * Stores the Fix definition in a temporary file with the given suffix. + * + * @param fixDef the Fix definition + * @param suffix the file suffix + * + * @return the path to the temporary file + */ public static String absPathToTempFile(final Reader fixDef, final String suffix) throws IOException { // TODO: avoid temp file creation final File file = File.createTempFile("metafix", suffix); diff --git a/metafix/src/main/java/org/metafacture/metafix/JsonValue.java b/metafix/src/main/java/org/metafacture/metafix/JsonValue.java index d01a74ae7..edead94fe 100644 --- a/metafix/src/main/java/org/metafacture/metafix/JsonValue.java +++ b/metafix/src/main/java/org/metafacture/metafix/JsonValue.java @@ -32,12 +32,29 @@ @FunctionalInterface public interface JsonValue { + /** + * Generates the JSON serialization. + * + * @param jsonGenerator the JSON generator + */ void toJson(JsonGenerator jsonGenerator); + /** + * Converts the value to JSON without pretty printing. + * + * @return the JSON serialization + */ default String toJson() throws IOException { return toJson(false); } + /** + * Converts the value to JSON with optional pretty printing. + * + * @param prettyPrinting true if pretty printing should be used + * + * @return the JSON serialization + */ default String toJson(final boolean prettyPrinting) throws IOException { final StringWriter writer = new StringWriter(); final JsonGenerator jsonGenerator = new JsonFactory().createGenerator(writer); @@ -59,9 +76,19 @@ class Parser { private static final ObjectMapper MAPPER = new ObjectMapper(); + /** + * Creates an instance of {@link Parser}. + */ public Parser() { } + /** + * Parses the JSON serialization. + * + * @param source the JSON serialization + * + * @return the deserialized value + */ public Value parse(final String source) throws IOException { return parse(MAPPER.readTree(source)); } diff --git a/metafix/src/main/java/org/metafacture/metafix/ListFixPaths.java b/metafix/src/main/java/org/metafacture/metafix/ListFixPaths.java index 891dd4cf5..c4e9d1aaa 100644 --- a/metafix/src/main/java/org/metafacture/metafix/ListFixPaths.java +++ b/metafix/src/main/java/org/metafacture/metafix/ListFixPaths.java @@ -37,16 +37,32 @@ @FluxCommand("list-fix-paths") public class ListFixPaths extends MetafixStreamAnalyzer { + /** + * Creates an instance of {@link ListFixPaths}. + */ public ListFixPaths() { super("nothing()", Compare.PREDICATE); setIndex(false); } + /** + * Flags whether to output individual repeated subfields and array elements + * with index numbers. + * + * @param index true if index numbers should be output + */ public void setIndex(final boolean index) { getFix().setEntityMemberName(index ? Metafix.DEFAULT_ENTITY_MEMBER_NAME : "*"); } + /** + * Checks whether to output individual repeated subfields and array elements + * with index numbers. + * + * @return true if index numbers should be output + */ public boolean getIndex() { return getFix().getEntityMemberName().equals(Metafix.DEFAULT_ENTITY_MEMBER_NAME); } + } diff --git a/metafix/src/main/java/org/metafacture/metafix/ListFixValues.java b/metafix/src/main/java/org/metafacture/metafix/ListFixValues.java index bb56b590e..316ac026d 100644 --- a/metafix/src/main/java/org/metafacture/metafix/ListFixValues.java +++ b/metafix/src/main/java/org/metafacture/metafix/ListFixValues.java @@ -36,6 +36,11 @@ @FluxCommand("list-fix-values") public class ListFixValues extends MetafixStreamAnalyzer { + /** + * Creates an instance of {@link ListFixValues}. + * + * @param path the Fix path to list values for + */ public ListFixValues(final String path) { super(fix(path), Compare.OBJECT); } diff --git a/metafix/src/main/java/org/metafacture/metafix/Metafix.java b/metafix/src/main/java/org/metafacture/metafix/Metafix.java index 478d6268e..e684a7ea6 100644 --- a/metafix/src/main/java/org/metafacture/metafix/Metafix.java +++ b/metafix/src/main/java/org/metafacture/metafix/Metafix.java @@ -104,19 +104,38 @@ public class Metafix implements StreamPipe, Maps { private boolean strictnessHandlesProcessExceptions; private int entityCount; + /** + * Creates an instance of {@link Metafix}. + */ public Metafix() { this(NO_VARS); } - public Metafix(final Map newVars) { - init(newVars); + /** + * Creates an instance of {@link Metafix}. + * + * @param vars the Fix variables as a Map + */ + public Metafix(final Map vars) { + init(vars); recordTransformer = null; } + /** + * Creates an instance of {@link Metafix}. + * + * @param fixDef the Fix definition + */ public Metafix(final String fixDef) throws IOException { this(fixDef, NO_VARS); } + /** + * Creates an instance of {@link Metafix}. + * + * @param fixDef the Fix definition + * @param vars the Fix variables as a Map + */ public Metafix(final String fixDef, final Map vars) throws IOException { init(vars); @@ -131,10 +150,21 @@ public Metafix(final String fixDef, final Map vars) throws IOExc } } + /** + * Creates an instance of {@link Metafix}. + * + * @param fixDef the Fix definition + */ public Metafix(final Reader fixDef) { this(fixDef, NO_VARS); } + /** + * Creates an instance of {@link Metafix}. + * + * @param fixDef the Fix definition + * @param vars the Fix variables as a Map + */ public Metafix(final Reader fixDef, final Map vars) { init(vars); recordTransformer = getRecordTransformer(fixDef); @@ -160,6 +190,15 @@ public void literal(final String name, final String value) { return fixDef.endsWith(FIX_EXTENSION); } + /** + * Resolves the path and caches the result. A valid URL is returned as is; a + * path starting with {@code .} is resolved relative to the current Fix + * file. The path will be normalized. + * + * @param path the path to resolve + * + * @return the resolved (and normalized) path + */ public String resolvePath(final String path) { return pathCache.computeIfAbsent(path, this::resolvePathInternal); } @@ -207,6 +246,13 @@ private Path getPath(final String path) { return Paths.get(path).toAbsolutePath().normalize(); } + /** + * Creates a record transformer for the Fix definition and caches the result. + * + * @param fixDef the Fix definition + * + * @return the record transformer + */ public RecordTransformer getRecordTransformer(final String fixDef) { return fixCache.computeIfAbsent(fixDef, k -> new RecordTransformer(this, FixStandaloneSetup.parseFix(k))); } @@ -215,10 +261,23 @@ private RecordTransformer getRecordTransformer(final Reader fixDef) { return new RecordTransformer(this, FixStandaloneSetup.parseFix(fixDef)); } + /** + * Registers a record transformer as Fix macro under the given name. + * + * @param name the name of the macro + * @param macro the record transformer + */ public void putMacro(final String name, final RecordTransformer macro) { macros.put(name, macro); } + /** + * Retrieves the previously registered Fix macro. + * + * @param name the name of the macro + * + * @return the record transformer + */ public RecordTransformer getMacro(final String name) { final RecordTransformer macro = macros.get(name); @@ -229,6 +288,11 @@ public RecordTransformer getMacro(final String name) { return macro; } + /** + * Gets the Fix expressions. + * + * @return the Fix expressions + */ public List getExpressions() { return expressions; } @@ -380,14 +444,29 @@ public R setReceiver(final R streamReceiver) { return streamReceiver; } + /** + * Gets the output stream receiver. + * + * @return the output stream receiver + */ public StreamReceiver getStreamReceiver() { return outputStreamReceiver; } + /** + * Gets the Fix variables. + * + * @return the Fix variables + */ public Map getVars() { return vars; } + /** + * Gets the current record. + * + * @return the current record + */ public Record getCurrentRecord() { return currentRecord; } @@ -422,34 +501,78 @@ public String putValue(final String mapName, final String key, final String valu return maps.computeIfAbsent(mapName, k -> new HashMap<>()).put(key, value); } + /** + * Sets the desired strictness level. + * + * @param strictness the strictness level + */ public void setStrictness(final Strictness strictness) { this.strictness = strictness != null ? strictness : DEFAULT_STRICTNESS; } + /** + * Gets the selected strictness level. + * + * @return the strictness level + */ public Strictness getStrictness() { return strictness; } + /** + * Flags whether {@link Strictness} should handle + * {@link FixProcessException process exceptions} as well. + * + * @param strictnessHandlesProcessExceptions true if Strictness should + * handle process exceptions + */ public void setStrictnessHandlesProcessExceptions(final boolean strictnessHandlesProcessExceptions) { this.strictnessHandlesProcessExceptions = strictnessHandlesProcessExceptions; } + /** + * Checks whether {@link Strictness} should handle + * {@link FixProcessException process exceptions} as well. + * + * @return true if Strictness should handle process exceptions + */ public boolean getStrictnessHandlesProcessExceptions() { return strictnessHandlesProcessExceptions; } + /** + * Flags whether repeated fields should always be emitted as array entities. + * + * @param repeatedFieldsToEntities true if repeated fields should be emitted + * as array entities + */ public void setRepeatedFieldsToEntities(final boolean repeatedFieldsToEntities) { this.repeatedFieldsToEntities = repeatedFieldsToEntities; } + /** + * Checks whether repeated fields should always be emitted as array entities. + * + * @return true if repeated fields should be emitted as array entities + */ public boolean getRepeatedFieldsToEntities() { return repeatedFieldsToEntities; } + /** + * Sets the field name for array entity members. + * + * @param entityMemberName the field name for array entity members + */ public void setEntityMemberName(final String entityMemberName) { this.entityMemberName = entityMemberName; } + /** + * Gets the field name for array entity members. + * + * @return the field name for array entity members + */ public String getEntityMemberName() { return entityMemberName; } @@ -461,7 +584,7 @@ private boolean maxEntityCountExceeded() { public enum Strictness { /** - * Aborts process by throwing an exception. + * Aborts the process by throwing an exception. */ PROCESS { @Override @@ -471,7 +594,7 @@ protected void handleInternal(final MetafactureException exception, final Record }, /** - * Ignores (skips) record and logs an error. + * Ignores (skips) the record and logs an error. */ RECORD { @Override @@ -482,7 +605,7 @@ protected void handleInternal(final MetafactureException exception, final Record }, /** - * Ignores (skips) expression and logs a warning. + * Ignores (skips) the expression and logs a warning. */ EXPRESSION { @Override @@ -491,6 +614,12 @@ protected void handleInternal(final MetafactureException exception, final Record } }; + /** + * Handles the exception based on the selected strictness level. + * + * @param exception the exception to be handled + * @param record the current record + */ public void handle(final MetafactureException exception, final Record record) { LOG.info("Current record: {}", record); handleInternal(exception, record); diff --git a/metafix/src/main/java/org/metafacture/metafix/Record.java b/metafix/src/main/java/org/metafacture/metafix/Record.java index adadd6fc2..0c336696f 100644 --- a/metafix/src/main/java/org/metafacture/metafix/Record.java +++ b/metafix/src/main/java/org/metafacture/metafix/Record.java @@ -62,7 +62,7 @@ public Record shallowClone() { /** * Flags whether this record should be rejected. * - * @param reject true if this record should not be emitted, false otherwise + * @param reject true if this record should not be emitted */ public void setReject(final boolean reject) { this.reject = reject; @@ -71,7 +71,7 @@ public void setReject(final boolean reject) { /** * Checks whether this record should be rejected. * - * @return true if this record should not be emitted, false otherwise + * @return true if this record should not be emitted, otherwise false */ public boolean getReject() { return reject; @@ -81,7 +81,8 @@ public boolean getReject() { * Checks whether this record contains the virtual field. * * @param field the field name - * @return true if this record contains the virtual field, false otherwise + * + * @return true if this record contains the virtual field, otherwise false */ public boolean containsVirtualField(final String field) { return virtualFields.containsKey(field); @@ -116,6 +117,7 @@ public String toString() { * {@link #containsField(String) present}. * * @param field the field name + * * @return the metadata value */ @Override @@ -141,7 +143,7 @@ public Value get(final String field) { * virtual fields into regular metadata fields if they're not already * {@link #containsField(String) present}. * - * @param field the field name + * @param field the field name * @param newValue the new metadata value */ @Override @@ -154,6 +156,12 @@ public void add(final String field, final Value newValue) { } } + /** + * Adds a nested field/value pair to this record. + * + * @param field the field name + * @param newValue the new metadata value + */ public void addNested(final String field, final Value newValue) { new FixPath(field).insertInto(this, InsertMode.APPEND, newValue); } @@ -162,7 +170,7 @@ public void addNested(final String field, final Value newValue) { * Sets a field/value pair to this record, replacing * any previous association of the field with a value. * - * @param field the field name + * @param field the field name * @param newValue the new metadata value */ public void set(final String field, final Value newValue) { @@ -193,8 +201,8 @@ public void retainFields(final Collection fields) { /** * Transform this record by applying the given operator to all matching values for the given field. * - * @param field The field - * @param operator The operator + * @param field the field + * @param operator the operator */ public void transform(final String field, final UnaryOperator operator) { final FixPath findPath = new FixPath(field); @@ -219,8 +227,8 @@ public void transform(final String field, final UnaryOperator operator) /** * Transform this record by consuming all matching values for the given field with the given consumer. * - * @param field The field - * @param consumer The consumer + * @param field the field + * @param consumer the consumer */ public void transform(final String field, final BiConsumer> consumer) { final FixPath path = new FixPath(field); diff --git a/metafix/src/main/java/org/metafacture/metafix/RecordTransformer.java b/metafix/src/main/java/org/metafacture/metafix/RecordTransformer.java index 5f118efdb..4809cd490 100644 --- a/metafix/src/main/java/org/metafacture/metafix/RecordTransformer.java +++ b/metafix/src/main/java/org/metafacture/metafix/RecordTransformer.java @@ -109,6 +109,12 @@ private RecordTransformer childTransformer(final List expressions) { return new RecordTransformer(metafix, expressions, this); } + /** + * Transforms the record. + * + * @param record the record to transform + * @param dynamicVars the dynamic variables to apply during transformation + */ public void transform(final Record record, final Map dynamicVars) { final Map oldDynamicVars = setVars(Vars.DYNAMIC, dynamicVars); @@ -120,6 +126,11 @@ public void transform(final Record record, final Map dynamicVars } } + /** + * Transforms the record. + * + * @param record the record to transform + */ public void transform(final Record record) { consumers.forEach(consumer -> { final MetafactureException exception = tryRun(() -> consumer.accept(record)); diff --git a/metafix/src/main/java/org/metafacture/metafix/Value.java b/metafix/src/main/java/org/metafacture/metafix/Value.java index 25d544966..5f97c4ac7 100644 --- a/metafix/src/main/java/org/metafacture/metafix/Value.java +++ b/metafix/src/main/java/org/metafacture/metafix/Value.java @@ -82,10 +82,20 @@ private Value(final Type type, final Array array, final Hash hash, final String this.string = string; } + /** + * Creates an instance of {@link Value} representing an {@link Array}. + * + * @param array the Array + */ public Value(final Array array) { this(array != null ? Type.Array : null, array, null, null); } + /** + * Creates an instance of {@link Value} representing an {@link Array}. + * + * @param array the array as a List + */ public Value(final List array) { this(array != null ? new Array() : null); @@ -94,10 +104,20 @@ public Value(final List array) { } } + /** + * Creates an instance of {@link Value} representing a {@link Hash}. + * + * @param hash the Hash + */ public Value(final Hash hash) { this(hash != null ? Type.Hash : null, null, hash, null); } + /** + * Creates an instance of {@link Value} representing a {@link Hash}. + * + * @param hash the hash as a Map + */ public Value(final Map hash) { this(hash != null ? new Hash() : null); @@ -106,18 +126,40 @@ public Value(final Map hash) { } } + /** + * Creates an instance of {@link Value} representing a String. + * + * @param string the String + */ public Value(final String string) { this(string != null ? Type.String : null, null, null, string); } + /** + * Creates an instance of {@link Value} representing a String. + * + * @param integer the string as an Integer + */ public Value(final int integer) { this(String.valueOf(integer)); } + /** + * Creates an instance of {@link Value} representing an {@link Array}. + * + * @return the new Value + */ public static Value newArray() { return newArray(null); } + /** + * Creates an instance of {@link Value} representing an {@link Array}. + * + * @param consumer the optional Array consumer + * + * @return the new Value + */ public static Value newArray(final Consumer consumer) { final Array array = new Array(); @@ -128,10 +170,22 @@ public static Value newArray(final Consumer consumer) { return new Value(array); } + /** + * Creates an instance of {@link Value} representing a {@link Hash}. + * + * @return the new Value + */ public static Value newHash() { return newHash(null); } + /** + * Creates an instance of {@link Value} representing a {@link Hash}. + * + * @param consumer the optional Hash consumer + * + * @return the new Value + */ public static Value newHash(final Consumer consumer) { final Hash hash = new Hash(); @@ -142,14 +196,29 @@ public static Value newHash(final Consumer consumer) { return new Value(hash); } + /** + * Checks whether the Value is of type Array. + * + * @return true if the Value is of type Array, otherwise false + */ public boolean isArray() { return isType(Type.Array); } + /** + * Checks whether the Value is of type Hash. + * + * @return true if the Value is of type Hash, otherwise false + */ public boolean isHash() { return isType(Type.Hash); } + /** + * Checks whether the Value is of type String. + * + * @return true if the Value is of type String, otherwise false + */ public boolean isString() { return isType(Type.String); } @@ -158,10 +227,22 @@ private boolean isType(final Type targetType) { return type == targetType; } + /** + * Checks whether the Value has no type. + * + * @return true if the Value has no type, otherwise false + */ public boolean isNull() { return isType(null); } + /** + * Checks whether the given Value has no type. + * + * @param value the Value + * + * @return true if the Value is {@code null} or has no type, otherwise false + */ public static boolean isNull(final Value value) { return value == null || value.isNull(); } @@ -170,22 +251,60 @@ public static boolean isNull(final Value value) { return s.matches("\\d+"); } + /** + * Extracts the Array from the Value. + * + * @return the Array + * + * @throws IllegalStateException if the Value is not an Array + */ public Array asArray() { return extractType((m, c) -> m.ifArray(c).orElseThrow()); } + /** + * Extracts the Hash from the Value. + * + * @return the Hash + * + * @throws IllegalStateException if the Value is not a Hash + */ public Hash asHash() { return extractType((m, c) -> m.ifHash(c).orElseThrow()); } + /** + * Extracts the String from the Value. + * + * @return the String + * + * @throws IllegalStateException if the Value is not a String + */ public String asString() { return extractType((m, c) -> m.ifString(c).orElseThrow()); } + /** + * Converts the given Value into a new Value representing an Array if it + * isn't already. + * + * @param value the Value + * @param consumer the consumer + * + * @return the Array + */ public static Value asList(final Value value, final Consumer consumer) { return isNull(value) ? null : value.asList(consumer); } + /** + * Converts the Value into a new Value representing an Array if it isn't + * already. + * + * @param consumer the consumer + * + * @return the Array + */ public Value asList(final Consumer consumer) { if (isArray()) { if (consumer != null) { @@ -205,10 +324,23 @@ public Value asList(final Consumer consumer) { } } + /** + * Creates a TypeMatcher for the Value. + * + * @return the TypeMatcher + */ public TypeMatcher matchType() { return new TypeMatcher(this); } + /** + * Extracts a result based on the Value's type. + * + * @param the type of the result + * @param consumer the consumer + * + * @return the result + */ public T extractType(final BiConsumer> consumer) { final AtomicReference result = new AtomicReference<>(); consumer.accept(matchType(), result::set); @@ -280,6 +412,11 @@ public void toJson(final JsonGenerator jsonGenerator) { return fieldPath.split(FIELD_PATH_SEPARATOR); } + /** + * Gets the Value's path. + * + * @return the path + */ public String getPath() { return path; } @@ -327,24 +464,61 @@ private TypeMatcher(final Value value) { this.value = value; } + /** + * Performs the consumer if the Value represents an Array. + * + * @param consumer the consumer + * + * @return the TypeMatcher + * + * @throws IllegalStateException if already matching for Array + */ public TypeMatcher ifArray(final Consumer consumer) { return match(Type.Array, consumer, value.array); } + /** + * Performs the consumer if the Value represents an Hash. + * + * @param consumer the consumer + * + * @return the TypeMatcher + * + * @throws IllegalStateException if already matching for Hash + */ public TypeMatcher ifHash(final Consumer consumer) { return match(Type.Hash, consumer, value.hash); } + /** + * Performs the consumer if the Value represents an String. + * + * @param consumer the consumer + * + * @return the TypeMatcher + * + * @throws IllegalStateException if already matching for String + */ public TypeMatcher ifString(final Consumer consumer) { return match(Type.String, consumer, value.string); } + /** + * Performs the consumer if the Value represents an unmatched type. + * + * @param consumer the consumer + */ public void orElse(final Consumer consumer) { if (!expected.contains(value.type)) { consumer.accept(value); } } + /** + * Throws an exception if the Value represents an unmatched type. + * + * @throws IllegalStateException if the Value represents an unmatched type + */ public void orElseThrow() { orElse(v -> { final String types = expected.stream().map(Type::name).collect(Collectors.joining(" or ")); @@ -428,6 +602,12 @@ public static class Array extends AbstractValueType { private Array() { } + /** + * Adds the given Value to the Array and appends the index number to its + * path. + * + * @param value the Value + */ public void add(final Value value) { add(value, true); } @@ -454,18 +634,42 @@ private void updateIndexesInPathsAfter(final int start) { } } + /** + * Checks whether the Array contains no elements. + * + * @return true if the Array contains no elements, otherwise false + */ public boolean isEmpty() { return list.isEmpty(); } + /** + * Returns the number of elements in this Array. + * + * @return the number of elements in this Array + */ public int size() { return list.size(); } + /** + * Returns the element at the specified position in this Array. + * + * @param index the index of the element to return + * + * @return the element at the specified position in this Array + * + * @throws IndexOutOfBoundsException if the index is out of range + */ public Value get(final int index) { return list.get(index); } + /** + * Returns a sequential Stream with this Array as its source. + * + * @return a sequential Stream over the elements in this Array + */ public Stream stream() { return list.stream(); } @@ -521,6 +725,11 @@ private Set findFields(final String pattern) { return fieldSet; } + /** + * Performs the given consumer for each element of the Array. + * + * @param consumer the consumer + */ public void forEach(final Consumer consumer) { list.forEach(consumer); } @@ -561,6 +770,13 @@ public void toJson(final JsonGenerator jsonGenerator) { } } + /** + * Removes the element at the specified position in this Array. + * + * @param index the index of the element to be removed + * + * @throws IndexOutOfBoundsException if the index is out of range + */ public void remove(final int index) { list.remove(index); } @@ -609,12 +825,19 @@ protected Hash() { * Checks whether this hash contains the metadata field. * * @param field the field name - * @return true if this hash contains the metadata field, false otherwise + * @return true if this hash contains the metadata field, otherwise false */ public boolean containsField(final String field) { return !findFields(field).isEmpty(); } + /** + * Checks whether this Hash contains a Value at the given Fix path. + * + * @param fieldPath the Fix path + * + * @return true if this Hash contains a Value at the path, otherwise false + */ public boolean containsPath(final String fieldPath) { final String[] path = split(fieldPath); final String field = path[0]; @@ -644,7 +867,7 @@ public boolean containsPath(final String fieldPath) { /** * Checks whether this hash is empty. * - * @return true if this hash is empty, false otherwise + * @return true if this hash is empty, otherwise false */ public boolean isEmpty() { return map.isEmpty(); @@ -709,6 +932,13 @@ public Value get(final String field) { )); } + /** + * Retrieves the Value for the given field name. + * + * @param field the field name + * + * @return the Value + */ public Value getField(final String field) { return map.get(field); } @@ -723,14 +953,33 @@ private Value getField(final String field, final boolean enforceStringValue) { return value; } + /** + * Retrieves the Value for the given field name represented as an Array. + * + * @param field the field name + * @param consumer the consumer + * + * @return the Value + */ public Value getList(final String field, final Consumer consumer) { return asList(get(field), consumer); } + /** + * Adds all values at the given field name. + * + * @param field the field name + * @param values the values + */ public void addAll(final String field, final List values) { values.forEach(value -> add(field, new Value(value))); } + /** + * Adds all key/value pairs from the given Hash. + * + * @param hash the Hash + */ public void addAll(final Hash hash) { hash.forEach(this::add); } @@ -762,7 +1011,7 @@ public void add(final String field, final Value newValue) { /** * Removes the given field/value pair from this hash. * - * @param field the field name + * @param field the Fix path */ public void remove(final String field) { final FixPath fixPath = new FixPath(field); @@ -775,6 +1024,11 @@ public void remove(final String field) { } } + /** + * Removes the given field/value pair from this hash. + * + * @param field the field name + */ public void removeField(final String field) { map.remove(field); } diff --git a/metafix/src/main/java/org/metafacture/metafix/api/FixContext.java b/metafix/src/main/java/org/metafacture/metafix/api/FixContext.java index afebc021c..d4de80be0 100644 --- a/metafix/src/main/java/org/metafacture/metafix/api/FixContext.java +++ b/metafix/src/main/java/org/metafacture/metafix/api/FixContext.java @@ -26,6 +26,15 @@ @FunctionalInterface public interface FixContext { + /** + * Executes the Fix context. + * + * @param metafix the Metafix instance + * @param record the record + * @param params the parameters + * @param options the options + * @param recordTransformer the record transformer + */ void execute(Metafix metafix, Record record, List params, Map options, RecordTransformer recordTransformer); } diff --git a/metafix/src/main/java/org/metafacture/metafix/api/FixFunction.java b/metafix/src/main/java/org/metafacture/metafix/api/FixFunction.java index 458a02335..4fb7891d6 100644 --- a/metafix/src/main/java/org/metafacture/metafix/api/FixFunction.java +++ b/metafix/src/main/java/org/metafacture/metafix/api/FixFunction.java @@ -35,18 +35,50 @@ @FunctionalInterface public interface FixFunction { + /** + * Applies the Fix function. + * + * @param metafix the Metafix instance + * @param record the record + * @param params the parameters + * @param options the options + */ void apply(Metafix metafix, Record record, List params, Map options); + /** + * Performs the consumer on the specified option. + * + * @param options the options + * @param key the option name + * @param consumer the consumer to perform + */ default void withOption(final Map options, final String key, final Consumer consumer) { withOption(options, key, consumer, Map::get); } + /** + * Performs the consumer on the specified option. + * + * @param the type of the option + * @param options the options + * @param key the option name + * @param consumer the consumer to perform + * @param function the function to retrieve the option + */ default void withOption(final Map options, final String key, final Consumer consumer, final BiFunction, String, T> function) { if (options.containsKey(key)) { consumer.accept(function.apply(options, key)); } } + /** + * Performs the consumer on an object writer configured with the given + * options. + * + * @param options the options + * @param operator the optional operator to transform the destination + * @param consumer the consumer to perform + */ default void withWriter(final Map options, final UnaryOperator operator, final Consumer> consumer) { final String destination = options.getOrDefault("destination", ObjectWriter.STDOUT); final ObjectWriter writer = new ObjectWriter<>(operator != null ? operator.apply(destination) : destination); @@ -66,6 +98,16 @@ default void withWriter(final Map options, final UnaryOperator options, final Map scopedCounter, final Consumer> consumer) { final Value idValue = record.get(options.getOrDefault("id", StandardEventNames.ID)); @@ -79,27 +121,72 @@ default void withWriter(final Metafix metafix, final Record record, final Map consumer.accept(s -> w.process(prefix + s))); } + /** + * Parses the specified option as a Boolean. + * + * @param options the options + * @param key the option name + * + * @return the Boolean + */ default boolean getBoolean(final Map options, final String key) { return Boolean.parseBoolean(options.get(key)); } + /** + * Parses the specified option as an Integer. + * + * @param options the options + * @param key the option name + * + * @return the Integer + */ default int getInteger(final Map options, final String key) { return Integer.parseInt(options.get(key)); } + /** + * Parses the specified parameter as an Integer. + * + * @param params the parameters + * @param index the parameter index + * + * @return the Integer + */ default int getInteger(final List params, final int index) { return Integer.parseInt(params.get(index)); } + /** + * Creates a new Array from the given stream. + * + * @param stream the Value stream + * + * @return the new Value + */ default Value newArray(final Stream stream) { return Value.newArray(a -> stream.forEach(a::add)); } + /** + * Removes duplicates from the given stream. + * + * @param stream the Value stream + * + * @return the unique Value stream + */ default Stream unique(final Stream stream) { final Set set = new HashSet<>(); return stream.filter(set::add); } + /** + * Flattens the given stream. + * + * @param stream the Value stream + * + * @return the flattened Value stream + */ default Stream flatten(final Stream stream) { return stream.flatMap(v -> v.extractType((m, c) -> m .ifArray(a -> c.accept(flatten(a.stream()))) diff --git a/metafix/src/main/java/org/metafacture/metafix/api/FixPredicate.java b/metafix/src/main/java/org/metafacture/metafix/api/FixPredicate.java index 201ee920f..167ede094 100644 --- a/metafix/src/main/java/org/metafacture/metafix/api/FixPredicate.java +++ b/metafix/src/main/java/org/metafacture/metafix/api/FixPredicate.java @@ -57,8 +57,28 @@ public interface FixPredicate { .ifString(s -> c.accept(s.isEmpty())) ); + /** + * Tests the given record against the predicate. + * + * @param metafix the Metafix instance + * @param record the record + * @param params the parameters + * @param options the options + * + * @return true if the record matches the predicate, otherwise false + */ boolean test(Metafix metafix, Record record, List params, Map options); + /** + * Tests the field value against the target string according to the qualified conditional. + * + * @param record the record + * @param params the field name and the target string + * @param qualifier the qualifier + * @param conditional the conditional + * + * @return true if the record matches the qualified conditional + */ default boolean testConditional(final Record record, final List params, final BiPredicate, Predicate> qualifier, final BiPredicate conditional) { final String field = params.get(0); final String string = params.get(1); @@ -70,6 +90,15 @@ default boolean testConditional(final Record record, final List params, )); } + /** + * Tests the field value against the conditional. + * + * @param record the record + * @param params the field name + * @param conditional the conditional + * + * @return true if the record matches the conditional + */ default boolean testConditional(final Record record, final List params, final Predicate conditional) { final String field = params.get(0); @@ -77,10 +106,27 @@ default boolean testConditional(final Record record, final List params, return value != null && conditional.test(value); } + /** + * Tests the parameters against the conditional. + * + * @param params the parameters + * @param conditional the conditional + * + * @return true if the parameters match the conditional + */ default boolean testConditional(final List params, final BiPredicate conditional) { return conditional.test(params.get(0), params.get(1)); } + /** + * Tests the field value against the conditional. + * + * @param record the record + * @param params the field name + * @param conditional the conditional + * + * @return true if the record matches the conditional + */ default boolean testStringConditional(final Record record, final List params, final Predicate conditional) { return testConditional(record, params, v -> v.extractType((m, c) -> m .ifString(s -> c.accept(conditional.test(s))) diff --git a/metafix/src/main/java/org/metafacture/metafix/interpreter/FixInterpreter.java b/metafix/src/main/java/org/metafacture/metafix/interpreter/FixInterpreter.java index fd6717906..1b2bb7333 100644 --- a/metafix/src/main/java/org/metafacture/metafix/interpreter/FixInterpreter.java +++ b/metafix/src/main/java/org/metafacture/metafix/interpreter/FixInterpreter.java @@ -22,9 +22,18 @@ public class FixInterpreter extends XbaseInterpreter { private Metafix metafix; + /** + * Creates an instance of {@link FixInterpreter}. + */ public FixInterpreter() { } + /** + * Interprets the Fix program. + * + * @param metafixParam the Metafix instance + * @param program the Fix instance + */ public void run(final Metafix metafixParam, final EObject program) { if (metafixParam != null && program != null) { metafix = metafixParam; diff --git a/metafix/src/main/java/org/metafacture/metafix/jvmmodel/FixJvmModelInferrer.java b/metafix/src/main/java/org/metafacture/metafix/jvmmodel/FixJvmModelInferrer.java index ae08a5cf8..c71650057 100644 --- a/metafix/src/main/java/org/metafacture/metafix/jvmmodel/FixJvmModelInferrer.java +++ b/metafix/src/main/java/org/metafacture/metafix/jvmmodel/FixJvmModelInferrer.java @@ -24,9 +24,19 @@ public class FixJvmModelInferrer extends AbstractModelInferrer { @Extension private IQualifiedNameProvider iQualifiedNameProvider; + /** + * Creates an instance of {@link FixJvmModelInferrer}. + */ public FixJvmModelInferrer() { } + /** + * Infers the JVM model. + * + * @param fix the Fix instance + * @param acceptor the acceptor + * @param isPrelinkingPhase true if prelinking phase + */ public void infer(final EObject fix, final IJvmDeclaredTypeAcceptor acceptor, final boolean isPrelinkingPhase) { if (fix == null) { throw new IllegalArgumentException("Unhandled parameter types: " + diff --git a/metafix/src/main/java/org/metafacture/metafix/scoping/FixScopeProvider.java b/metafix/src/main/java/org/metafacture/metafix/scoping/FixScopeProvider.java index 14f0a75a2..8ffeb4625 100644 --- a/metafix/src/main/java/org/metafacture/metafix/scoping/FixScopeProvider.java +++ b/metafix/src/main/java/org/metafacture/metafix/scoping/FixScopeProvider.java @@ -8,6 +8,9 @@ */ public class FixScopeProvider extends AbstractFixScopeProvider { + /** + * Creates an instance of {@link FixScopeProvider}. + */ public FixScopeProvider() { } diff --git a/metafix/src/main/java/org/metafacture/metafix/validation/FixValidator.java b/metafix/src/main/java/org/metafacture/metafix/validation/FixValidator.java index 600112f12..65375be88 100644 --- a/metafix/src/main/java/org/metafacture/metafix/validation/FixValidator.java +++ b/metafix/src/main/java/org/metafacture/metafix/validation/FixValidator.java @@ -7,6 +7,9 @@ */ public class FixValidator extends AbstractFixValidator { + /** + * Creates an instance of {@link FixValidator}. + */ public FixValidator() { } diff --git a/metafix/src/main/java/org/metafacture/metafix/validation/XtextValidator.java b/metafix/src/main/java/org/metafacture/metafix/validation/XtextValidator.java index 5427598e4..ecceb4e0c 100644 --- a/metafix/src/main/java/org/metafacture/metafix/validation/XtextValidator.java +++ b/metafix/src/main/java/org/metafacture/metafix/validation/XtextValidator.java @@ -44,6 +44,14 @@ private static boolean validate(final XtextResource resource, final ISetup setup return true; } + /** + * Validates the resource. + * + * @param path the path to the resource + * @param setup the resource setup + * + * @return true if the resource is valid, otherwise false + */ public static boolean validate(final String path, final ISetup setup) { return validate(getResource(path, setup), setup); } @@ -63,6 +71,16 @@ private static XtextResource getResource(final String path, final ISetup setup) .getInstance(XtextResourceSet.class).getResource(URI.createFileURI(absolutePath), true); } + /** + * Parses and validates the resource. + * + * @param path the path to the resource + * @param setup the resource setup + * + * @return the resource + * + * @throws FixParseException if the resource is invalid + */ public static XtextResource getValidatedResource(final String path, final ISetup setup) { final XtextResource resource = getResource(path, setup); @@ -78,6 +96,12 @@ private static String resourceType(final ISetup setup) { return setup.getClass().getSimpleName(); } + /** + * Validates the Xtext file. Exits with error code {@code 1} if validation + * fails. + * + * @param args the pathname of the Xtext file to validate + */ public static void main(final String[] args) { if (args != null && args.length == 1) { System.exit(validate(args[0], new XtextStandaloneSetup()) ? 0 : 1); diff --git a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Concat.java b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Concat.java index 20cf40c22..29c4442ef 100644 --- a/metamorph/src/main/java/org/metafacture/metamorph/collectors/Concat.java +++ b/metamorph/src/main/java/org/metafacture/metamorph/collectors/Concat.java @@ -68,7 +68,7 @@ public void setDelimiter(final String delimiter) { } /** - * Flasg whether the concatenation should be reversely done. + * Flags whether the concatenation should be done reversely. * * @param reverse true if concatenation should be done reversely */