Skip to content

Commit

Permalink
Updated serialization mode
Browse files Browse the repository at this point in the history
  • Loading branch information
keilw committed Apr 17, 2023
1 parent 260d01a commit d4a0515
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@
* This interface is used to provide a <code>getDescription()</code> method to enums.
*
* @author Werner Keil
* @version 0.4
* @version 1.0
* @param <D> the value parameter
* @since 1.0.2
*/
public interface DescriptiveEnum<D extends DescriptiveEnum<D>> extends DescriptionSupplier {

String name(); // this is just a compatibility measure with the original enum

String getDescription();
default String getDescription() {
return "";
}

DescriptiveEnum<D>[] dValues();
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,34 @@
* @since 2.2
* @see UnitFormat
*/
public enum SerializationMode {
public enum SerializationMode implements DescriptiveEnum<SerializationMode> {
/**
* Serialization-mode using {@code SimpleUnitFormat}. This is the <strong>default</strong> mode if none is explicitly selected.
*/
SIMPLE,
SIMPLE("Simple formatting"),
/**
* Serialization-mode using an {@code EBNF} instance of {@link UnitFormat}.
* @see <a href="https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form">Wikipedia: Extended Backus–Naur form</a>
*/
EBNF,
EBNF("EBNF style formatting"),
/**
* Serialization-mode using a {@code UCUM} instance of {@link UnitFormat}.
*/
UCUM
};
UCUM("UCUM based formatting");

private final String description;

private SerializationMode(final String desc) {
this.description = desc;
}

@Override
public String getDescription() {
return description;
}

@Override
public DescriptiveEnum<SerializationMode>[] dValues() {
return SerializationMode.values();
}
}

0 comments on commit d4a0515

Please sign in to comment.