Skip to content

Commit

Permalink
Add missing Javadoc comments to metafacture-fix methods/constructors. (
Browse files Browse the repository at this point in the history
  • Loading branch information
blackwinter committed Jan 30, 2025
1 parent 60f8e4e commit 2f57d06
Show file tree
Hide file tree
Showing 33 changed files with 784 additions and 20 deletions.
4 changes: 2 additions & 2 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<property name="files" value="xtext-gen"/>
</module>
<module name="SuppressionSingleFilter">
<property name="checks" value="MultipleStringLiterals|ExecutableStatementCount|MagicNumber"/>
<property name="checks" value="ExecutableStatementCount|MagicNumber|MissingJavadocMethod|MultipleStringLiterals"/>
<property name="files" value="test"/>
</module>
<module name="TreeWalker">
Expand Down Expand Up @@ -93,7 +93,7 @@
<module name="MethodTypeParameterName"/>
<module name="MissingCtor"/>
<module name="MissingDeprecated"/>
<!--<module name="MissingJavadocMethod"/>-->
<module name="MissingJavadocMethod"/>
<module name="MissingOverride"/>
<module name="MissingSwitchDefault"/>
<module name="ModifiedControlVariable"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
* Use this class to register ide components.
*/
public class FixIdeModule extends AbstractFixIdeModule {

/**
* Creates an instance of {@link FixIdeModule}.
*/
public FixIdeModule() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/
public class FixIdeSetup extends FixStandaloneSetup {

/**
* Creates an instance of {@link FixIdeSetup}.
*/
public FixIdeSetup() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public class FixServlet extends XtextServlet {

private DisposableRegistry disposableRegistry;

/**
* Creates an instance of {@link FixServlet}.
*/
public FixServlet() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
* application.
*/
public class FixWebModule extends AbstractFixWebModule {

/**
* Creates an instance of {@link FixWebModule}.
*/
public FixWebModule() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*/
public class FixWebSetup extends FixStandaloneSetup {

/**
* Creates an instance of {@link FixWebSetup}.
*/
public FixWebSetup() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public class BaselineBenchmark extends AbstractBenchmark {

/**
* Creates an instance of {@link BaselineBenchmark}.
*/
public BaselineBenchmark() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class MetafixBenchmark extends FixParseBenchmark { // checkstyle-disable-
})
private String input;

/**
* Creates an instance of {@link MetafixBenchmark}.
*/
public MetafixBenchmark() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,15 @@
@FluxCommand("find-fix-paths")

public class FindFixPaths extends DefaultStreamPipe<ObjectReceiver<String>> {

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 {
Expand Down Expand Up @@ -103,4 +109,5 @@ protected void onCloseStream() {
protected void onResetStream() {
fix.resetStream();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<FixInterpreter> bindFixInterpreter() {
return FixInterpreter.class;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -27,10 +36,26 @@ public static void main(final String[] args) {
throw new IllegalArgumentException(String.format("Usage: %s <fix-file>", 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"));
Expand All @@ -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);
Expand Down
27 changes: 27 additions & 0 deletions metafix/src/main/java/org/metafacture/metafix/JsonValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
}
Expand Down
16 changes: 16 additions & 0 deletions metafix/src/main/java/org/metafacture/metafix/ListFixPaths.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Loading

0 comments on commit 2f57d06

Please sign in to comment.