From dfba0dd624c4d3e0b1eb6ac61b94f96f5b4e604d Mon Sep 17 00:00:00 2001 From: Peter Powers <pmpowers@usgs.gov> Date: Sun, 20 Jun 2021 13:10:49 -0600 Subject: [PATCH] immutable max-dir factor map --- .../nshmp/www/services/MaxDirection.java | 52 ++++++++++--------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/services/MaxDirection.java b/src/main/java/gov/usgs/earthquake/nshmp/www/services/MaxDirection.java index 9f377c661..e35c59355 100644 --- a/src/main/java/gov/usgs/earthquake/nshmp/www/services/MaxDirection.java +++ b/src/main/java/gov/usgs/earthquake/nshmp/www/services/MaxDirection.java @@ -23,41 +23,43 @@ import static gov.usgs.earthquake.nshmp.gmm.Imt.SA4P0; import static gov.usgs.earthquake.nshmp.gmm.Imt.SA5P0; import static gov.usgs.earthquake.nshmp.gmm.Imt.SA7P5; +import java.util.Collections; import java.util.EnumMap; import java.util.Map; import gov.usgs.earthquake.nshmp.gmm.Imt; /* - * Max direction factors derived from Shahi and Baker (2012) and used in the - * BSSC. + * Max direction map derived from Shahi and Baker (2012) and used in the BSSC. */ class MaxDirection { - static final Map<Imt, Double> FACTORS = new EnumMap<>(Imt.class); + static final Map<Imt, Double> FACTORS; static { - FACTORS.put(PGA, 1.0); - FACTORS.put(SA0P01, 1.200); - FACTORS.put(SA0P02, 1.200); - FACTORS.put(SA0P03, 1.200); - FACTORS.put(SA0P05, 1.200); - FACTORS.put(SA0P075, 1.200); - FACTORS.put(SA0P1, 1.200); - FACTORS.put(SA0P15, 1.200); - FACTORS.put(SA0P2, 1.200); - FACTORS.put(SA0P25, 1.203); - FACTORS.put(SA0P3, 1.206); - FACTORS.put(SA0P4, 1.213); - FACTORS.put(SA0P5, 1.219); - FACTORS.put(SA0P75, 1.234); - FACTORS.put(SA1P0, 1.250); - FACTORS.put(SA1P5, 1.253); - FACTORS.put(SA2P0, 1.256); - FACTORS.put(SA3P0, 1.261); - FACTORS.put(SA4P0, 1.267); - FACTORS.put(SA5P0, 1.272); - FACTORS.put(SA7P5, 1.286); - FACTORS.put(SA10P0, 1.300); + Map<Imt, Double> map = new EnumMap<>(Imt.class); + map.put(PGA, 1.0); + map.put(SA0P01, 1.200); + map.put(SA0P02, 1.200); + map.put(SA0P03, 1.200); + map.put(SA0P05, 1.200); + map.put(SA0P075, 1.200); + map.put(SA0P1, 1.200); + map.put(SA0P15, 1.200); + map.put(SA0P2, 1.200); + map.put(SA0P25, 1.203); + map.put(SA0P3, 1.206); + map.put(SA0P4, 1.213); + map.put(SA0P5, 1.219); + map.put(SA0P75, 1.234); + map.put(SA1P0, 1.250); + map.put(SA1P5, 1.253); + map.put(SA2P0, 1.256); + map.put(SA3P0, 1.261); + map.put(SA4P0, 1.267); + map.put(SA5P0, 1.272); + map.put(SA7P5, 1.286); + map.put(SA10P0, 1.300); + FACTORS = Collections.unmodifiableMap(map); } } -- GitLab