summaryrefslogtreecommitdiff
path: root/src/org/unitConverter/converterGUI/DefaultPrefixRepetitionRule.java
blob: 34d8467bff2e7a2ef522a0e05aae01bc272759fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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<List<UnitPrefix>> {
	NO_REPETITION {
		@Override
		public boolean test(List<UnitPrefix> prefixes) {
			return prefixes.size() <= 1;
		}
	},
	NO_RESTRICTION {
		@Override
		public boolean test(List<UnitPrefix> 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<UnitPrefix> prefixes) {
			// TODO method stub
			return false;
		}
	};
}