1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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();
}
}
|