diff --git a/console/systems/common-java14/pom.xml b/console/systems/common-java14/pom.xml deleted file mode 100644 index b477e3ff..00000000 --- a/console/systems/common-java14/pom.xml +++ /dev/null @@ -1,139 +0,0 @@ - - 4.0.0 - - tech.uom.demo.console.systems - uom-console-system-demos - 2.1-SNAPSHOT - - uom-console-demos-common-java14 - UoM Common Console Demos for Java 14 - - - - - - 14 - ${jdkVersion} - ${jdkVersion} - ${jdkVersion} - tech.uom.demo.systems.common14.AirplaneDemo - - - - - javax.measure - unit-api - - - tech.units - indriya - - - si.uom - si-quantity - - - systems.uom - systems-quantity - - - systems.uom - systems-common - - - tech.uom.lib - uom-lib-common - - - org.junit.jupiter - junit-jupiter - test - - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${jdkVersion} - --enable-preview - true - true - 14 - 14 - - - - - maven-surefire-plugin - - --enable-preview - - - - org.apache.maven.plugins - maven-compiler-plugin - - 14 - 14 - - - - org.apache.maven.plugins - maven-compiler-plugin - - 14 - 14 - - - - org.apache.maven.plugins - maven-compiler-plugin - - 14 - 14 - - - - org.apache.maven.plugins - maven-compiler-plugin - - 14 - 14 - - - - org.apache.maven.plugins - maven-compiler-plugin - - 14 - 14 - - - - - - org.codehaus.mojo - exec-maven-plugin - 3.0.0 - - - - java - - - - - ${runClass} - - - - - \ No newline at end of file diff --git a/console/systems/common-java14/src/main/java/module-info.java b/console/systems/common-java14/src/main/java/module-info.java deleted file mode 100644 index 2effe9c6..00000000 --- a/console/systems/common-java14/src/main/java/module-info.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Units of Measurement Console Demos - * Copyright (c) 2005-2020, Werner Keil and others. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of JSR-385, Unit-API nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -module tech.uom.demo.systems.common14 { - requires transitive java.measure; - requires transitive tech.units.indriya; - requires tech.uom.lib.common; - requires systems.uom.common; - - exports tech.uom.demo.systems.common14; - exports tech.uom.demo.systems.common14.types; -} \ No newline at end of file diff --git a/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/AirplaneDemo.java b/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/AirplaneDemo.java deleted file mode 100644 index bcda7065..00000000 --- a/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/AirplaneDemo.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Units of Measurement Console Demos - * Copyright (c) 2005-2021, Werner Keil and others. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of JSR-385, Unit-API nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tech.uom.demo.systems.common14; - -import static systems.uom.common.USCustomary.MILE_PER_HOUR; -import static systems.uom.common.USCustomary.MILE; -import static tech.units.indriya.unit.Units.HOUR; -import static tech.units.indriya.unit.Units.KILOMETRE_PER_HOUR; - -import java.time.Duration; - -import javax.measure.Quantity; -import javax.measure.quantity.Length; -import javax.measure.quantity.Speed; -import javax.measure.quantity.Time; - -import tech.units.indriya.AbstractQuantity; -import tech.units.indriya.quantity.Quantities; -import tech.units.indriya.quantity.time.TemporalQuantity; -import tech.units.indriya.quantity.time.TimeQuantities; - -import tech.uom.demo.systems.common14.types.Airplane; - -/** - * This is a simple example for an In-Flight Infotainment (IFI) system showing the plane's cruising speed or time to destination. - * - * @author Werner Keil - * @see Wikipedia: In-flight entertainment - */ -public class AirplaneDemo { - - public static void main(String[] args) { - final String model; - double dist; - if (args != null && args.length > 0) { - dist = Double.parseDouble(args[0]); - if (args.length > 1) { - model = args[1]; - } else { - model = "A380"; - } - } else { // default fallback - dist = 6089d; - model = "A380"; - } - // TODO make distance parseable as a quantity like "6089 mi" or similar - var distance = Quantities.getQuantity(dist, MILE); - var airplane = new Airplane(model); - var airplaneSpeed = airplane.getSpeed(); - System.out.println(airplane + " flying " + airplaneSpeed); - System.out.println(airplane + " flying " + airplaneSpeed.to(MILE_PER_HOUR)); - var timeToDest = distance.divide(airplaneSpeed).asType(Time.class); - - var tuqToDest = TimeQuantities.toTemporalSeconds(timeToDest); - System.out.println("TTD: " + timeToDest.to(HOUR)); - System.out.println("TTD (Duration): " + Duration.from(tuqToDest.getTemporalAmount())); - } -} \ No newline at end of file diff --git a/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/Messages.java b/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/Messages.java deleted file mode 100644 index 46ed1d6c..00000000 --- a/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/Messages.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Units of Measurement Demos for Java - * Copyright (c) 2005-2020, Werner Keil and others. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of JSR-385, Units of Measurement nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tech.uom.demo.systems.common14; - -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * Local helper class for i18n and resource bundles - * @author Werner Keil - * - */ -class Messages { - private static final String BUNDLE_NAME = Messages.class.getPackage().getName() + ".messages"; //$NON-NLS-1$ - - private static ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); - - private Messages() { - } - - /** - * Loads the string using the default locale or using a language provided via -Dlanguage={lang}. - * @param key - * @param missingKeyOnly if the key is missing, return the key only and no "!" - * @return the local string or an error message including the key - */ - public static String getString(String key, boolean missingKeyOnly) { - final String language = System.getProperty("language"); - if (language != null) { - if (!language.equals(RESOURCE_BUNDLE.getLocale().getLanguage())) { - //System.out.println(language); - RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, new Locale(language)); - } - } - try { - return RESOURCE_BUNDLE.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } - - /** - * Retrieves the string - * @param key - * @return - */ - public static String getString(String key) { - return getString(key, false); - } -} diff --git a/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/ThePerfectStorm.java b/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/ThePerfectStorm.java deleted file mode 100644 index 1f4afe0f..00000000 --- a/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/ThePerfectStorm.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Units of Measurement Console Demos - * Copyright (c) 2005-2020, Werner Keil and others. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of JSR-385, Units of Measurement nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tech.uom.demo.systems.common14; - -import static javax.measure.MetricPrefix.KILO; -import static systems.uom.common.USCustomary.MILE_PER_HOUR; -import static tech.units.indriya.quantity.Quantities.getQuantity; -import static tech.units.indriya.unit.Units.KILOMETRE_PER_HOUR; -import static tech.units.indriya.unit.Units.METRE; -import static tech.uom.demo.systems.common14.types.SaffirSimpsonHurricaneWindScale.Category.*; - -import tech.units.indriya.format.SimpleUnitFormat; -import tech.uom.demo.systems.common14.types.SaffirSimpsonHurricaneWindScale; - -import javax.measure.quantity.Time; -import java.util.regex.Pattern; - -/** - * @author Werner Keil - * @version 1.3 - * @see {@link SaffirSimpsonHurricaneWindScale} - */ -public class ThePerfectStorm { - // Constants - private static final SaffirSimpsonHurricaneWindScale STD = SaffirSimpsonHurricaneWindScale.of( - null, getQuantity(38, MILE_PER_HOUR), TROPICAL_DEPRESSION); - private static final SaffirSimpsonHurricaneWindScale STS = SaffirSimpsonHurricaneWindScale.of( - getQuantity(39, MILE_PER_HOUR), getQuantity(73, MILE_PER_HOUR), TROPICAL_STORM); - private static final SaffirSimpsonHurricaneWindScale S1 = SaffirSimpsonHurricaneWindScale.of( - getQuantity(74, MILE_PER_HOUR), getQuantity(95, MILE_PER_HOUR), ONE); - private static final SaffirSimpsonHurricaneWindScale S2 = SaffirSimpsonHurricaneWindScale.of( - getQuantity(96, MILE_PER_HOUR), getQuantity(110, MILE_PER_HOUR), TWO); - private static final SaffirSimpsonHurricaneWindScale S3 = SaffirSimpsonHurricaneWindScale.of( - getQuantity(111, MILE_PER_HOUR), getQuantity(129, MILE_PER_HOUR), THREE); - private static final SaffirSimpsonHurricaneWindScale S4 = SaffirSimpsonHurricaneWindScale.of( - getQuantity(130, MILE_PER_HOUR), getQuantity(156, MILE_PER_HOUR), FOUR); - private static final SaffirSimpsonHurricaneWindScale S5 = SaffirSimpsonHurricaneWindScale.of( - getQuantity(157, MILE_PER_HOUR), null, FIVE); - - private static final double DEFAULT_DIST_KM = 500d; - - /** - * @param args - */ - public static void main(String[] args) { - boolean verbose = false; - if (args != null && args.length > 0 && !isNumeric(args[0])) { - if ("-v".equals(args[0])) verbose = true; - } - - var argument = -1; - var distKm = DEFAULT_DIST_KM; - - if (verbose) { - System.out.println(STD); - System.out.println(STS); - System.out.println(S1); - System.out.println(S2); - System.out.println(S3); - System.out.println(S4); - System.out.println(S5); - - if (args != null && args.length > 1 && isNumeric(args[1])) { - argument = Integer.valueOf(args[1]).intValue(); - } - if (args != null && args.length > 2 && isNumeric(args[2])) { - distKm = Double.valueOf(args[2]).doubleValue(); - } - } else { - if (args != null && args.length > 0 && isNumeric(args[0])) { - argument = Integer.valueOf(args[0]).intValue(); - } - if (args != null && args.length > 1 && isNumeric(args[1])) { - distKm = Double.valueOf(args[1]).doubleValue(); - } - } - - // With Java 14 the switch/case segment gets much more compact - var scale = switch (argument) { - case 0 -> STS; - case 1 -> S1; - case 2 -> S2; - case 3 -> S3; - case 4 -> S4; - case 5 -> S5; - default -> STD; - }; - - // If the wind scale has a maximum we take that assuming the worst case, otherwise the minimum - final var metricSpeed = scale.hasMaximum() ? - scale.getMaximum().to(KILOMETRE_PER_HOUR) : - scale.getMinimum().to(KILOMETRE_PER_HOUR); - - System.out.print(metricSpeed); - System.out.println(" (" + Messages.getString("SaffirSimpsonHurricaneWindScale." + scale.getCategory(), true) - + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - final var distance = getQuantity(distKm, KILO(METRE)); - System.out.println(String.format(Messages.getString("ThePerfectStorm.1"), distance)); //$NON-NLS-1$ - final var timeToEvacuate = distance.divide(metricSpeed).asType(Time.class); - SimpleUnitFormat.getInstance().label(timeToEvacuate.getUnit(), "h"); - System.out.println(String.format(Messages.getString("ThePerfectStorm.3"), timeToEvacuate)); //$NON-NLS-1$ - } - - private static final Pattern PATTERN = Pattern.compile("-?\\d+(\\.\\d+)?"); - - private static boolean isNumeric(String strNum) { - if (strNum == null) { - return false; - } - return PATTERN.matcher(strNum).matches(); - } -} diff --git a/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/types/Airplane.java b/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/types/Airplane.java deleted file mode 100644 index e2d8c1ab..00000000 --- a/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/types/Airplane.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Units of Measurement Console Demos - * Copyright (c) 2005-2021, Werner Keil and others. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of JSR-385, Unit-API nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tech.uom.demo.systems.common14.types; - -import static tech.units.indriya.unit.Units.KILOMETRE_PER_HOUR; - -import javax.measure.Quantity; -import javax.measure.quantity.Speed; -import javax.measure.quantity.Time; - -import tech.units.indriya.AbstractQuantity; -import tech.units.indriya.quantity.Quantities; - -/** - * This is a demonstrator for the Java 14 {@link Record} preview and the new switch expression. - * @author Werner Keil - * - */ -public record Airplane( String model) { - - public final Quantity getSpeed() { - return switch (model) { - case "A380" -> Quantities.getQuantity(945, KILOMETRE_PER_HOUR); // Airbus A 380 Cruise speed - case "B777" -> Quantities.getQuantity(892, KILOMETRE_PER_HOUR); - // Boeing 777 Cruise speed, see https://en.wikipedia.org/wiki/Boeing_777#Specifications - case "B787" -> Quantities.getQuantity(903, KILOMETRE_PER_HOUR); - // Boeing 787 Cruise speed, see https://en.wikipedia.org/wiki/Boeing_787_Dreamliner#Specifications - default -> AbstractQuantity.NONE.asType(Speed.class); - }; - } -} diff --git a/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/types/SaffirSimpsonHurricaneWindScale.java b/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/types/SaffirSimpsonHurricaneWindScale.java deleted file mode 100644 index 84ee97d9..00000000 --- a/console/systems/common-java14/src/main/java/tech/uom/demo/systems/common14/types/SaffirSimpsonHurricaneWindScale.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Units of Measurement Console Demos - * Copyright (c) 2005-2020, Werner Keil and others. - * - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * - * 3. Neither the name of JSR-385, Units of Measurement nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package tech.uom.demo.systems.common14.types; - -import static tech.units.indriya.AbstractQuantity.NONE; -import static tech.uom.demo.systems.common14.types.SaffirSimpsonHurricaneWindScale.Category.*; - -import javax.measure.Quantity; -import javax.measure.quantity.Speed; - -import tech.uom.lib.common.function.Nameable; -import tech.units.indriya.quantity.QuantityRange; - -/** - * @author Werner Keil - * @version 1.1 - * @see - * Wikipedia: Saffir–Simpson hurricane wind scale - */ -public class SaffirSimpsonHurricaneWindScale extends QuantityRange - implements Nameable { - - /** - * The storm category - */ - public static enum Category { - UNKNOWN, TROPICAL_DEPRESSION, TROPICAL_STORM, ONE, TWO, THREE, FOUR, FIVE - } - - private final Category category; - - public Category getCategory() { - return category; - } - - /* - * (non-Javadoc) - * - * @see Range - */ - protected SaffirSimpsonHurricaneWindScale(Quantity min, - Quantity max, Category level) { - super(min, max); - this.category = level; - } - - /* - * (non-Javadoc) - * - * @see Range - */ - protected SaffirSimpsonHurricaneWindScale(Quantity min, - Quantity max) { - this(min, max, UNKNOWN); - } - - /** - * Returns an {@code SaffirSimpsonHurricaneWindScale} with the specified - * values. - * - * @param min - * The minimum value for the wind scale. - * @param max - * The maximum value for the wind scale. - * @param cat - * The {@link Category} of the wind scale. - * @return an {@code SaffirSimpsonHurricaneWindScale} with the values - * present - */ - public static final SaffirSimpsonHurricaneWindScale of(Quantity min, - Quantity max, Category cat) { - return new SaffirSimpsonHurricaneWindScale(min, max, cat); - } - - @Override - public boolean hasMinimum() { - return getMinimum() != null - && !NONE.equals(getMinimum()) - && !(getMinimum().getUnit() == null || getMinimum().getValue() == null); - } - - @Override - public boolean hasMaximum() { - return getMaximum() != null - && !NONE.equals(getMaximum()) - && !(getMaximum().getUnit() == null || getMaximum().getValue() == null); - } - - @Override - public String toString() { - return getName() + " [category=" + category + ", minimum=" - + getMinimum() + ", maximum=" + getMaximum() + "]"; - } - - @Override - public String getName() { - return "Saffir–Simpson hurricane wind scale"; - } -} diff --git a/console/systems/common-java14/src/main/resources/tech/uom/demo/systems/common14/messages.properties b/console/systems/common-java14/src/main/resources/tech/uom/demo/systems/common14/messages.properties deleted file mode 100644 index 773c8d4e..00000000 --- a/console/systems/common-java14/src/main/resources/tech/uom/demo/systems/common14/messages.properties +++ /dev/null @@ -1,14 +0,0 @@ - -SaffirSimpsonHurricaneWindScale.FIVE = Category 5 -SaffirSimpsonHurricaneWindScale.FOUR = Category 4 -SaffirSimpsonHurricaneWindScale.ONE = Category 1 -SaffirSimpsonHurricaneWindScale.THREE = Category 3 -SaffirSimpsonHurricaneWindScale.TROPICAL_DEPRESSION = Tropical Depression -SaffirSimpsonHurricaneWindScale.TROPICAL_STORM = Tropical Storm -SaffirSimpsonHurricaneWindScale.TWO = Category 2 -SaffirSimpsonHurricaneWindScale.UNKNOWN = Unknown - -ThePerfectStorm.1 = Distance: %s -ThePerfectStorm.2 = h -ThePerfectStorm.3 = Time to evacuate: %s -ThePerfectStorm.4 = No scale given. diff --git a/console/systems/common-java14/src/main/resources/tech/uom/demo/systems/common14/messages_de.properties b/console/systems/common-java14/src/main/resources/tech/uom/demo/systems/common14/messages_de.properties deleted file mode 100644 index 6718eb84..00000000 --- a/console/systems/common-java14/src/main/resources/tech/uom/demo/systems/common14/messages_de.properties +++ /dev/null @@ -1,12 +0,0 @@ -ThePerfectStorm.1=Entfernung: %s -ThePerfectStorm.2=std -ThePerfectStorm.3=Zeit zu Evakuieren: %s -ThePerfectStorm.4=Keine Skala angegeben. -SaffirSimpsonHurricaneWindScale.TROPICAL_DEPRESSION=Tropische Depression -SaffirSimpsonHurricaneWindScale.TROPICAL_STORM=Tropischer Sturm -SaffirSimpsonHurricaneWindScale.ONE=Kategorie 1 -SaffirSimpsonHurricaneWindScale.TWO=Kategorie 2 -SaffirSimpsonHurricaneWindScale.THREE=Kategorie 3 -SaffirSimpsonHurricaneWindScale.FOUR=Kategorie 4 -SaffirSimpsonHurricaneWindScale.FIVE=Kategorie 5 -SaffirSimpsonHurricaneWindScale.UNKNOWN=Unbekannt \ No newline at end of file diff --git a/console/systems/common-java14/src/main/resources/tech/uom/demo/systems/common14/messages_es.properties b/console/systems/common-java14/src/main/resources/tech/uom/demo/systems/common14/messages_es.properties deleted file mode 100644 index 520a78a8..00000000 --- a/console/systems/common-java14/src/main/resources/tech/uom/demo/systems/common14/messages_es.properties +++ /dev/null @@ -1,12 +0,0 @@ -ThePerfectStorm.1=Distancia: %s -ThePerfectStorm.2=h -ThePerfectStorm.3=Tiempo de evacuación: %s -ThePerfectStorm.4=No se especifica escala. -SaffirSimpsonHurricaneWindScale.TROPICAL_DEPRESSION=Depresión tropical -SaffirSimpsonHurricaneWindScale.TROPICAL_STORM=Tormenta tropical -SaffirSimpsonHurricaneWindScale.ONE=Categoría 1 -SaffirSimpsonHurricaneWindScale.TWO=Categoría 2 -SaffirSimpsonHurricaneWindScale.THREE=Categoría 3 -SaffirSimpsonHurricaneWindScale.FOUR=Categoría 4 -SaffirSimpsonHurricaneWindScale.FIVE=Categoría 5 -SaffirSimpsonHurricaneWindScale.UNKNOWN=Desconocido \ No newline at end of file