Still allow serialisation of PlotTitle flag

This commit is contained in:
dordsor21 2021-08-22 15:58:15 +01:00
parent 4b26a7e300
commit fb8e749411
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
2 changed files with 8 additions and 2 deletions

View File

@ -233,7 +233,7 @@ public final class GlobalFlagContainer extends FlagContainer {
this.addFlag(DescriptionFlag.DESCRIPTION_FLAG_EMPTY);
this.addFlag(GreetingFlag.GREETING_FLAG_EMPTY);
this.addFlag(FarewellFlag.FAREWELL_FLAG_EMPTY);
this.addFlag(PlotTitleFlag.TITLE_FLAG_EMPTY);
this.addFlag(PlotTitleFlag.TITLE_FLAG_DEFAULT);
// Internal flags
this.addFlag(new AnalysisFlag(Collections.emptyList()));

View File

@ -33,7 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
public class PlotTitleFlag extends PlotFlag<PlotTitle, PlotTitleFlag> {
public static final PlotTitleFlag TITLE_FLAG_EMPTY = new PlotTitleFlag(PlotTitle.CONFIGURED);
public static final PlotTitleFlag TITLE_FLAG_DEFAULT = new PlotTitleFlag(PlotTitle.CONFIGURED);
/**
* Construct a new flag instance.
@ -50,6 +50,9 @@ public class PlotTitleFlag extends PlotFlag<PlotTitle, PlotTitleFlag> {
@Override
public PlotTitleFlag parse(@NonNull String input) throws FlagParseException {
if (input.equals("CONFIGURED")) {
return TITLE_FLAG_DEFAULT;
}
if (!input.contains("\"")) {
return new PlotTitleFlag(new PlotTitle(input, ""));
}
@ -82,6 +85,9 @@ public class PlotTitleFlag extends PlotFlag<PlotTitle, PlotTitleFlag> {
@Override
public String toString() {
if (getValue() == PlotTitle.CONFIGURED) {
return "CONFIGURED";
}
return "\"" + getValue().title() + "\" \"" + getValue().subtitle() + "\"";
}