diff options
author | Jesse Crocker <jesse@gaiagps.com> | 2017-03-01 11:15:11 -0700 |
---|---|---|
committer | Jesse Crocker <jesse@gaiagps.com> | 2017-03-01 11:15:11 -0700 |
commit | 9e8dc9a9e3e86adb9987ae69766cc42c7d9efece (patch) | |
tree | f5f0abd4d342c89ad0405d01969f9d6caecc1c90 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/Stops.java | |
parent | 16fb0672e64a72b7400c321d55858b73cd5d8c3f (diff) | |
parent | f28d75dccd9bf4a7615df87faccc5cf5eff8df89 (diff) | |
download | qtlocation-mapboxgl-9e8dc9a9e3e86adb9987ae69766cc42c7d9efece.tar.gz |
Merge remote-tracking branch 'origin/master' into feature/custom-vector-source
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/Stops.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/Stops.java | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/Stops.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/Stops.java new file mode 100644 index 0000000000..af4f53c072 --- /dev/null +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/functions/stops/Stops.java @@ -0,0 +1,99 @@ +package com.mapbox.mapboxsdk.style.functions.stops; + +import android.support.annotation.CallSuper; +import android.support.annotation.NonNull; +import android.support.annotation.Size; + +import java.util.HashMap; +import java.util.Map; + +/** + * The base class for different stops implementations + * + * @param <I> the input type + * @param <O> the output type + * @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#types-function">The style specification</a> + */ +public abstract class Stops<I, O> { + + /** + * Convenience method for use in function declarations + * + * @param stops the collections of discrete stops + * @param <I> the Stops input type + * @param <O> the Stops output type + * @return the {@link Stops} implementation + * @see Stop#stop + * @see CategoricalStops + */ + @SafeVarargs + public static <I, O> CategoricalStops<I, O> categorical(@NonNull @Size(min = 1) Stop<I, O>... stops) { + return new CategoricalStops<>(stops); + } + + /** + * Convenience method for use in function declarations + * + * @param stops the collections of discrete stops + * @param <I> the Stops input type + * @param <O> the Stops output type + * @return the {@link Stops} implementation + * @see Stop#stop + * @see ExponentialStops + */ + @SafeVarargs + public static <I, O> ExponentialStops<I, O> exponential(@NonNull @Size(min = 1) Stop<I, O>... stops) { + return new ExponentialStops<>(stops); + } + + /** + * Convenience method for use in function declarations + * + * @param <T> the Stops input/output type + * @return the {@link IdentityStops} implementation + * @see Stop#stop + * @see IdentityStops + */ + public static <T> IdentityStops<T> identity() { + return new IdentityStops<>(); + } + + /** + * Convenience method for use in function declarations + * + * @param stops the collections of discrete stops + * @param <I> the Stops input type + * @param <O> the Stops output type + * @return the {@link Stops} implementation + * @see Stop#stop + * @see IntervalStops + */ + @SafeVarargs + public static <I, O> IntervalStops<I, O> interval(@NonNull @Size(min = 1) Stop<I, O>... stops) { + return new IntervalStops<>(stops); + } + + /** + * INTERNAL USAGE ONLY + * + * @return the value object representation for conversion to core + */ + @CallSuper + public Map<String, Object> toValueObject() { + HashMap<String, Object> map = new HashMap<>(); + map.put("type", getTypeName()); + return map; + } + + /** + * INTERNAL USAGE ONLY + * + * @return the unique type name as a string according to the style specification + */ + protected abstract String getTypeName(); + + @Override + public String toString() { + return getTypeName(); + } +} |