Skip to content

Commit

Permalink
Minor refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed Nov 2, 2024
1 parent 4ea0541 commit 6f27d66
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@ public static void handleQuiet() {
}

protected void showVersion() {
@SuppressWarnings("resource")
PrintStream out = AnsiConsole.out(); // NOPMD - not owner
@SuppressWarnings("resource") PrintStream out = AnsiConsole.out(); // NOPMD - not owner
getVersionInfos().values().stream().forEach(info -> {
out.println(ansi()
.bold().a(info.getName()).boldOff()
Expand Down Expand Up @@ -254,8 +253,7 @@ public class CallingContext {

@SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW", justification = "Use of final fields")
public CallingContext(@NonNull List<String> args) {
@SuppressWarnings("PMD.LooseCoupling")
LinkedList<ICommand> calledCommands = new LinkedList<>();
@SuppressWarnings("PMD.LooseCoupling") LinkedList<ICommand> calledCommands = new LinkedList<>();
List<Option> options = new LinkedList<>(OPTIONS);
List<String> extraArgs = new LinkedList<>();

Expand Down Expand Up @@ -633,8 +631,7 @@ public void showHelp() {
HelpFormatter formatter = new HelpFormatter();
formatter.setLongOptSeparator("=");

@SuppressWarnings("resource")
AnsiPrintStream out = AnsiConsole.out();
@SuppressWarnings("resource") AnsiPrintStream out = AnsiConsole.out();

try (PrintWriter writer = new PrintWriter( // NOPMD not owned
AutoCloser.preventClose(out),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public final QName getDefinitionQName() {
return definitionQName.get();
}

@Override
public boolean isInline() {
// never inline
return false;
}

@Override
public final INSTANCE getInlineInstance() {
// never inline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public final DEFINITION getDefinition() {
return ObjectUtils.asType(this);
}

@Override
public boolean isInline() {
return true;
}

@Override
@NonNull
public final INSTANCE getInlineInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public final DEFINITION getDefinition() {
return ObjectUtils.asType(this);
}

@Override
public boolean isInline() {
return true;
}

@Override
@NonNull
public final INSTANCE getInlineInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ default String getRootJsonName() {
return getRootName();
}

@Override
default boolean isInline() {
// not inline by default
return false;
}

@Override
default IAssemblyInstance getInlineInstance() {
// not inline by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ default QName getDefinitionQName() {
/**
* Determine if the definition is defined inline, meaning the definition is
* declared where it is used.
* <p>
* If this method returns {@code false}, then {@link #getInlineInstance()} must
* return {@code null}.
*
* @return {@code true} if the definition is declared inline or {@code false} if
* the definition is able to be globally referenced
* @see #getInlineInstance()
*/
default boolean isInline() {
return getInlineInstance() != null;
Expand All @@ -71,8 +75,12 @@ default boolean isInline() {
/**
* If {@link #isInline()} is {@code true}, return the instance the definition is
* inlined for.
* <p>
* If this method returns {@code null}, then {@link #getInlineInstance()} must
* return {@code false}.
*
* @return the instance or {@code null} otherwise
* @see #isInline()
*/
INamedInstance getInlineInstance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ public interface IFeatureDefinitionInstanceInlined<
DEFINITION extends IDefinition,
INSTANCE extends INamedInstance>
extends IDefinition, INamedInstance {
@Override
default boolean isInline() {
// has to be inline
return true;
}

@Override
default QName getDefinitionQName() {
Expand All @@ -44,6 +39,12 @@ default DEFINITION getDefinition() {
return ObjectUtils.asType(this);
}

@Override
default boolean isInline() {
// has to be inline
return true;
}

@Override
@NonNull
default INSTANCE getInlineInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
import edu.umd.cs.findbugs.annotations.Nullable;

public interface IFieldDefinition extends IModelDefinition, IValuedDefinition, IField {

@Override
default boolean isInline() {
// not inline by default
return false;
}

@Override
default IFieldInstance getInlineInstance() {
// not inline by default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,7 @@ public List<Result> generateResults(@NonNull URI output) throws IOException {
assert constraint != null;
ConstraintRuleRecord rule = getRuleRecord(constraint);

@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
Result result = new Result();
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") Result result = new Result();

String id = constraint.getId();
if (id != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,7 @@ default IValidationResult validateWithSchema(
switch (asFormat) {
case JSON: {
JSONObject json;
try (@SuppressWarnings("resource")
InputStream is
try (@SuppressWarnings("resource") InputStream is
= new BufferedInputStream(ObjectUtils.notNull(targetResource.openStream()))) {
json = new JSONObject(new JSONTokener(is));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ default IBoundDefinitionModelField<Object> getDefinition() {
return IFeatureDefinitionInstanceInlined.super.getDefinition();
}

@Override
default boolean isInline() {
return IFeatureDefinitionInstanceInlined.super.isInline();
}

@Override
default IBoundInstanceModelFieldScalar getInlineInstance() {
return IFeatureDefinitionInstanceInlined.super.getInlineInstance();
Expand Down

0 comments on commit 6f27d66

Please sign in to comment.