1
|
package eu.dnetlib.clients.index.model;
|
2
|
|
3
|
import java.util.Date;
|
4
|
import java.util.Map;
|
5
|
|
6
|
/**
|
7
|
* Interface for a map with Any objects.
|
8
|
* <p>
|
9
|
* <p>
|
10
|
* AnyMap does <b>not</b> allow <code>null</code> values!
|
11
|
* </p>
|
12
|
*/
|
13
|
public interface AnyMap extends Any, Map<String, Any> {
|
14
|
|
15
|
/**
|
16
|
* Adds the given value to the mapped entry of the given key. If there's no mapping yet, the new value is added as
|
17
|
* Seq with one value. If the key is currently mapped to a Value/Map, the Value/Map is converted to a Seq containing
|
18
|
* the Value/Map and the Seq is added. If the key is currently mapped to a Seq, new value is added to that Seq.
|
19
|
*
|
20
|
* @param key The key
|
21
|
* @param value the Any to add
|
22
|
*/
|
23
|
void add(String key, Any value);
|
24
|
|
25
|
/**
|
26
|
* @param key The key
|
27
|
* @param value String value, must not be null.
|
28
|
* @return the previous value or null
|
29
|
*/
|
30
|
Any put(String key, String value);
|
31
|
|
32
|
/**
|
33
|
* Long, Integer, Short and Byte values will be converted to Value object of type LONG, all others to Value object
|
34
|
* of type DOUBLE.
|
35
|
*
|
36
|
* @param key The key
|
37
|
* @param value Number value, will be converted, must not be null.
|
38
|
* @return the previous value or null
|
39
|
*/
|
40
|
Any put(String key, Number value);
|
41
|
|
42
|
/**
|
43
|
* @param key The key
|
44
|
* @param value Boolean value, must not be null.
|
45
|
* @return the previous value or null
|
46
|
*/
|
47
|
Any put(String key, Boolean value);
|
48
|
|
49
|
/**
|
50
|
* @param key The key
|
51
|
* @param value Any value, must not be null.
|
52
|
* @return the previous value or null
|
53
|
*/
|
54
|
@Override
|
55
|
Any put(String key, Any value);
|
56
|
|
57
|
/**
|
58
|
* @param key The key
|
59
|
* @return The AnyMap matching the key, an InvalidValueTypeException is thrown if the value is not of type AnyMap,
|
60
|
* or null
|
61
|
*/
|
62
|
AnyMap getMap(String key);
|
63
|
|
64
|
/**
|
65
|
* Gets the map and optionally creates one under the given key if not present.
|
66
|
*
|
67
|
* @param key The key
|
68
|
* @param create if true and the key is not yet used, create a new map. else just return null.
|
69
|
* @return The AnyMap matching the key, an InvalidValueTypeException is thrown if the value is not of type AnyMap
|
70
|
*/
|
71
|
AnyMap getMap(String key, boolean create);
|
72
|
|
73
|
/**
|
74
|
* @param key The key
|
75
|
* @return The AnySeq matching to this key, an InvalidValueTypeException is thrown if the value is not of type, or
|
76
|
* null
|
77
|
*/
|
78
|
AnySeq getSeq(String key);
|
79
|
|
80
|
/**
|
81
|
* Gets the seq and optionally creates one under the given key if not present.
|
82
|
*
|
83
|
* @param key The key
|
84
|
* @param create the create
|
85
|
* @return The AnySeq matching the key, an InvalidValueTypeException is thrown if the value is not of type AnyMap
|
86
|
*/
|
87
|
AnySeq getSeq(String key, boolean create);
|
88
|
|
89
|
/**
|
90
|
* @param key the key
|
91
|
* @return The string representation of the attribute value
|
92
|
*/
|
93
|
String getStringValue(String key);
|
94
|
|
95
|
/**
|
96
|
* @param key the key
|
97
|
* @return The value matching to this key, an InvalidValueTypeException is thrown if the value is no value type
|
98
|
*/
|
99
|
Value getValue(String key);
|
100
|
|
101
|
/**
|
102
|
* @param key The key
|
103
|
* @return The double value matching to this key, an InvalidValueTypeException is thrown if the value is not of type
|
104
|
* double
|
105
|
*/
|
106
|
Double getDoubleValue(String key);
|
107
|
|
108
|
/**
|
109
|
* @param key The key
|
110
|
* @return The long value matching to this key, an InvalidValueTypeException is thrown if the value is not of type
|
111
|
* long
|
112
|
*/
|
113
|
Long getLongValue(String key);
|
114
|
|
115
|
/**
|
116
|
* @param key The key
|
117
|
* @return The boolean value matching to this key, an InvalidValueTypeException is thrown if the value is not of
|
118
|
* type boolean
|
119
|
*/
|
120
|
Boolean getBooleanValue(String key);
|
121
|
|
122
|
/**
|
123
|
* @param key The key
|
124
|
* @return The date value matching to this key, an InvalidValueTypeException is thrown if the value is not of type
|
125
|
* date
|
126
|
*/
|
127
|
Date getDateValue(String key);
|
128
|
|
129
|
/**
|
130
|
* @param key The key
|
131
|
* @return The date time value matching to this key, an InvalidValueTypeException is thrown if the value is not of
|
132
|
* type date time
|
133
|
*/
|
134
|
Date getDateTimeValue(String key);
|
135
|
}
|