/** * Copyright (C) 2022, 2024, 2025 Adrien Hopkins * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ package sevenUnits.unit; import java.util.function.Predicate; /** * A type of unit, as chosen by the type of system it is in. * * * @since 2022-04-10 * @since v0.4.0 */ public enum UnitType { /** Units that pass {@link Unit#isMetric} */ METRIC, /** certain exceptions like the degree Celsius */ SEMI_METRIC, /** Non-metric, non-excepted units */ NON_METRIC; /** * Determines which type a unit is. The type will be: * * * @param u unit to test * @param isSemiMetric predicate to determine if a unit is semi-metric * @return type of unit * @since 2022-04-18 * @since v0.4.0 */ public static final UnitType getType(Unit u, Predicate isSemiMetric) { if (isSemiMetric.test(u)) return SEMI_METRIC; if (u.isMetric()) return METRIC; return NON_METRIC; } }