Project

General

Profile

1
package eu.dnetlib.clients.index.model;
2

    
3
import java.util.Iterator;
4

    
5
/**
6
 * Interface for metadata objects.
7
 */
8
public interface Any extends Iterable<Any> {
9

    
10
	/**
11
	 * @return value type
12
	 */
13
	ValueType getValueType();
14

    
15
	;
16

    
17
	/**
18
	 * @return true if value is of type map
19
	 */
20
	boolean isMap();
21

    
22
	/**
23
	 * @return true if value is of type sequence
24
	 */
25
	boolean isSeq();
26

    
27
	/**
28
	 * @return true if value is of type value
29
	 */
30
	boolean isValue();
31

    
32
	/**
33
	 * @return true if value is of type string
34
	 */
35
	boolean isString();
36

    
37
	/**
38
	 * @return true if value is of type double
39
	 */
40
	boolean isDouble();
41

    
42
	/**
43
	 * @return true if value is of type boolean
44
	 */
45
	boolean isBoolean();
46

    
47
	/**
48
	 * @return true if value is of type long
49
	 */
50
	boolean isLong();
51

    
52
	/**
53
	 * @return true if value is of type date
54
	 */
55
	boolean isDate();
56

    
57
	/**
58
	 * @return true if value is of type date time
59
	 */
60
	boolean isDateTime();
61

    
62
	/**
63
	 * @return true if value is of type long or double
64
	 */
65
	boolean isNumber();
66

    
67
	/**
68
	 * @return data factory to create Anys of the same kind.
69
	 */
70
	DataFactory getFactory();
71

    
72
	/**
73
	 * @return iterator over elements. For {@link Value}, this return an iterator about the value itself. For
74
	 * {@link AnyMap} it returns an iterator on the values.
75
	 */
76
	@Override
77
	Iterator<Any> iterator();
78

    
79
	/**
80
	 * @return true, if the Any does not have content. For {@link Value}: returns always false.
81
	 */
82
	boolean isEmpty();
83

    
84
	/**
85
	 * @return size of Any. For {@link Value} this is always 1.
86
	 */
87
	int size();
88

    
89
	/**
90
	 * returns this Any as an {@link Value} object or throws an {@link InvalidValueTypeException}.
91
	 */
92
	Value asValue();
93

    
94
	/**
95
	 * returns this Any as an {@link AnyMap} object or throws an {@link InvalidValueTypeException}.
96
	 */
97
	AnyMap asMap();
98

    
99
	/**
100
	 * returns this Any as an {@link AnySeq} object or throws an {@link InvalidValueTypeException}.
101
	 */
102
	AnySeq asSeq();
103

    
104
	/**
105
	 * Enumeration with the possible value types.
106
	 */
107
	public enum ValueType {
108

    
109
		/**
110
		 * The list with the possible value types. MAP map, SEQ sequence, STRING string value, DOUBLE double value,
111
		 * BOOLEAN Boolean value, LONG long value, DATE date (without time), DATETIME date with time
112
		 */
113
		MAP, SEQ, STRING, DOUBLE, BOOLEAN, LONG, DATE, DATETIME
114
	}
115

    
116
}
(1-1/8)