From 6d7d172e2e706da44c2b30177a04648671aad69e Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Wed, 26 Aug 2020 12:37:12 -0500 Subject: Added the prefix repetition rule, and the two basic rules. --- .../converterGUI/DefaultPrefixRepetitionRule.java | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/org/unitConverter/converterGUI/DefaultPrefixRepetitionRule.java (limited to 'src/org/unitConverter/converterGUI/DefaultPrefixRepetitionRule.java') diff --git a/src/org/unitConverter/converterGUI/DefaultPrefixRepetitionRule.java b/src/org/unitConverter/converterGUI/DefaultPrefixRepetitionRule.java new file mode 100644 index 0000000..34d8467 --- /dev/null +++ b/src/org/unitConverter/converterGUI/DefaultPrefixRepetitionRule.java @@ -0,0 +1,42 @@ +/** + * @since 2020-08-26 + */ +package org.unitConverter.converterGUI; + +import java.util.List; +import java.util.function.Predicate; + +import org.unitConverter.unit.UnitPrefix; + +/** + * A rule that specifies whether prefix repetition is allowed + * + * @since 2020-08-26 + */ +enum DefaultPrefixRepetitionRule implements Predicate> { + NO_REPETITION { + @Override + public boolean test(List prefixes) { + return prefixes.size() <= 1; + } + }, + NO_RESTRICTION { + @Override + public boolean test(List prefixes) { + return true; + } + }, + /** + * You are allowed to have any number of Yotta/Yocto followed by possibly one + * Kilo-Zetta/Milli-Zepto followed by possibly one Deca/Hecto. Same for + * reducing prefixes, don't mix magnifying and reducing. Non-metric + * (including binary) prefixes can't be repeated. + */ + COMPLEX_REPETITION { + @Override + public boolean test(List prefixes) { + // TODO method stub + return false; + } + }; +} -- cgit v1.2.3