mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-24 21:13:50 +00:00
Merge branch 'master' into grib2
This commit is contained in:
commit
b458576894
183 files changed
+2015
-756
No files matched your search
@@ -384,9 +384,27 @@ public class Util {
|
||||
* made. This is the caller's obligation.
|
||||
*/
|
||||
public static <K, V> void addToValueSet(Map<K, Set<V>> map, K key, V value) {
|
||||
addToValueSet(map, key, value, new ValueSetConstructor<V>() {
|
||||
@Override
|
||||
public Set<V> createSet() {
|
||||
return new HashSet<V>();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static interface ValueSetConstructor<T> {
|
||||
Set<T> createSet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that a {@link Set Set<V>} is contained in {@code map} for {@code key} and
|
||||
* then adds {@code value} to that set. No synchronization / concurrency control effort is
|
||||
* made. This is the caller's obligation.
|
||||
*/
|
||||
public static <K, V> void addToValueSet(Map<K, Set<V>> map, K key, V value, ValueSetConstructor<V> setConstructor) {
|
||||
Set<V> set = map.get(key);
|
||||
if (set == null) {
|
||||
set = new HashSet<V>();
|
||||
set = setConstructor.createSet();
|
||||
map.put(key, set);
|
||||
}
|
||||
set.add(value);
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class KeywordMatcher<T> {
|
||||
private boolean containsText(T obj, Iterable<String> keywords) {
|
||||
boolean failed = false;
|
||||
for (String word : keywords) {
|
||||
String textAsUppercase = word.toUpperCase().trim();
|
||||
String textAsUppercase = word.toUpperCase();
|
||||
failed = true;
|
||||
for (String s : getStrings(obj)) {
|
||||
if (s != null && s.toUpperCase().contains(textAsUppercase)) {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sap.sse.common.util;
|
||||
|
||||
|
||||
public class RoundingUtil {
|
||||
public static final RoundingUtil distanceDecimalFormatter = new RoundingUtil(2);
|
||||
public static final RoundingUtil knotsDecimalFormatter = new RoundingUtil(2);
|
||||
public static final RoundingUtil bearingDecimalFormatter = new RoundingUtil(1);
|
||||
public static final RoundingUtil speedDecimalFormatter = new RoundingUtil(1);
|
||||
public static final RoundingUtil latLngDecimalFormatter = new RoundingUtil(6);
|
||||
|
||||
private final double shiftFactor;
|
||||
|
||||
private RoundingUtil(int decimals) {
|
||||
shiftFactor = getShiftFactor(decimals);
|
||||
}
|
||||
|
||||
private static double getShiftFactor(int decimals) {
|
||||
return Math.pow(10, decimals);
|
||||
}
|
||||
|
||||
public double format(double value) {
|
||||
return ((double) Math.round(value * shiftFactor)) / shiftFactor;
|
||||
}
|
||||
|
||||
public static double format(double value, int decimals) {
|
||||
final double shiftFactor = getShiftFactor(decimals);
|
||||
return ((double) Math.round(value * shiftFactor)) / shiftFactor;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user