This repository has been archived by the owner on Dec 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GenericAttributeType.java
124 lines (107 loc) · 3.39 KB
/
GenericAttributeType.java
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package de.chrgroth.generictypesystem.model;
import java.util.List;
/**
* The base interface for all attribute types.
*
* @author Christian Groth
*/
public interface GenericAttributeType {
/**
* Returns all valid java classe for this type.
*
* @return type classes
*/
List<Class<?>> getTypeClasses();
/**
* Checks if the type is numeric.
*
* @return true if the attribute type is numeric, false otherwise
*/
boolean isNumeric();
/**
* Checks if the type is text.
*
* @return true if the attribute type is text, false otherwise
*/
boolean isText();
/**
* Checks if the type is an enum.
*
* @return true if the attribute type is enum, false otherwise
*/
boolean isEnum();
/**
* Checks if the type is capable of min and max bounds.
*
* @return true if the attribute type is min and max capable, false otherwise
*/
boolean isMinMaxCapable();
/**
* Checks if the type is capable of step configuration.
*
* @return true if the attribute type is step capable, false otherwise
*/
boolean isStepCapable();
/**
* Checks if the type is capable of pattern validation.
*
* @return true if the attribute type is pattern capable, false otherwise
*/
boolean isPatternCapable();
/**
* Checks if the type is capable of value proposal dependencies.
*
* @return true if the attribute type is value proposal dependencies capable, false otherwise
*/
boolean isValueProposalDependenciesCapable();
/**
* Checks if the type is capable of units.
*
* @return true if the attribute type is unit capable, false otherwise
*/
boolean isUnitCapable();
/**
* Checks if the type is capable of default values.
*
* @return true if the attribute type is default valuecapable, false otherwise
*/
boolean isDefaultValueCapable();
/**
* Checks if the type is a list type.
*
* @return true if the attribute type represents a list, false otherwise
*/
boolean isList();
/**
* Checks if the type is a structured type.
*
* @return true if the attribute type represents a structure, false otherwise
*/
boolean isStructure();
/**
* Checks if the given class is assignable for the attribute type.
*
* @param actualClass
* class to be checked
* @return true if assignable, false otherwise
*/
boolean isAssignableFrom(Class<?> actualClass);
/**
* Tries to parse the given string value to an instance of the main type. If the value can't be parsed nul will be returned.
*
* @param value
* value to be parsed
* @return parsed value or null
*/
Object parse(String value);
/**
* Converts the given value from any class returning true for {@link #isAssignableFrom(Class)} to the java main type. Unfortunately the main type can't be
* expressed as generic on enumerations because of java language specification boundaries, so we need to return object. Sorry for that!! If
* {@link #isDefaultValueCapable()} returns false this method will always return null!
*
* @param value
* value to be converted
* @return converted value of null is {@link #isAssignableFrom(Class)} returns false
*/
Object convert(Object value);
}