@@ -43,66 +43,168 @@ class Props(val map: Map[String, String])(implicit conv: Converters = Converters
43
43
}
44
44
45
45
def getBoolean (key : String ): Maybe [Boolean ] = map.get(key) match {
46
- case Some (value) ⇒ conv.convertToBoolean(value)
47
- case None ⇒ NoVal
46
+ case Some (value) ⇒
47
+ conv.convertToBoolean(value)
48
+
49
+ case None ⇒
50
+ NoVal
51
+ }
52
+
53
+ def getBooleanEx (key : String ): Boolean = map.get(key) match {
54
+ case Some (value) ⇒
55
+ conv.convertToBooleanEx(value)
56
+
57
+ case None ⇒
58
+ throw new IllegalArgumentException (" Unknown key %s" .format(key))
48
59
}
49
60
50
61
def getByte (key : String ): Maybe [Byte ] = map.get(key) match {
51
- case Some (value) ⇒ conv.convertToByte(value)
52
- case None ⇒ NoVal
62
+ case Some (value) ⇒
63
+ conv.convertToByte(value)
64
+
65
+ case None ⇒
66
+ NoVal
67
+ }
68
+
69
+ def getByteEx (key : String ): Byte = map.get(key) match {
70
+ case Some (value) ⇒
71
+ conv.convertToByteEx(value)
72
+
73
+ case None ⇒
74
+ throw new IllegalArgumentException (" Unknown key %s" .format(key))
53
75
}
54
76
55
77
def getShort (key : String ): Maybe [Short ] = map.get(key) match {
56
- case Some (value) ⇒ conv.convertToShort(value)
57
- case None ⇒ NoVal
78
+ case Some (value) ⇒
79
+ conv.convertToShort(value)
80
+
81
+ case None ⇒
82
+ NoVal
83
+ }
84
+
85
+ def getShortEx (key : String ): Short = map.get(key) match {
86
+ case Some (value) ⇒
87
+ conv.convertToShortEx(value)
88
+
89
+ case None ⇒
90
+ throw new IllegalArgumentException (" Unknown key %s" .format(key))
58
91
}
59
92
60
93
def getInt (key : String ): Maybe [Int ] = map.get(key) match {
61
- case Some (value) ⇒ conv.convertToInt(value)
62
- case None ⇒ NoVal
94
+ case Some (value) ⇒
95
+ conv.convertToInt(value)
96
+
97
+ case None ⇒
98
+ NoVal
99
+ }
100
+
101
+ def getIntEx (key : String ): Int = map.get(key) match {
102
+ case Some (value) ⇒
103
+ conv.convertToIntEx(value)
104
+
105
+ case None ⇒
106
+ throw new IllegalArgumentException (" Unknown key %s" .format(key))
63
107
}
64
108
65
109
def getLong (key : String ): Maybe [Long ] = map.get(key) match {
66
- case Some (value) ⇒ conv.convertToLong(value)
67
- case None ⇒ NoVal
110
+ case Some (value) ⇒
111
+ conv.convertToLong(value)
112
+
113
+ case None ⇒
114
+ NoVal
68
115
}
69
-
116
+
117
+ def getLongEx (key : String ): Long = map.get(key) match {
118
+ case Some (value) ⇒
119
+ conv.convertToLongEx(value)
120
+
121
+ case None ⇒
122
+ throw new IllegalArgumentException (" Unknown key %s" .format(key))
123
+ }
124
+
70
125
def getDouble (key : String ): Maybe [Double ] = map.get(key) match {
71
- case Some (value) ⇒ conv.convertToDouble(value)
72
- case None ⇒ NoVal
126
+ case Some (value) ⇒
127
+ conv.convertToDouble(value)
128
+
129
+ case None ⇒
130
+ NoVal
131
+ }
132
+
133
+ def getDoubleEx (key : String ): Double = map.get(key) match {
134
+ case Some (value) ⇒
135
+ conv.convertToDoubleEx(value)
136
+
137
+ case None ⇒
138
+ throw new IllegalArgumentException (" Unknown key %s" .format(key))
73
139
}
74
140
75
141
def getFloat (key : String ): Maybe [Float ] = map.get(key) match {
76
- case Some (value) ⇒ conv.convertToFloat(value)
77
- case None ⇒ NoVal
142
+ case Some (value) ⇒
143
+ conv.convertToFloat(value)
144
+
145
+ case None ⇒
146
+ NoVal
147
+ }
148
+
149
+ def getFloatEx (key : String ): Float = map.get(key) match {
150
+ case Some (value) ⇒
151
+ conv.convertToFloatEx(value)
152
+
153
+ case None ⇒
154
+ throw new IllegalArgumentException (" Unknown key %s" .format(key))
78
155
}
79
156
80
157
def getProps (key : String ): Maybe [Props ] = map.get(key) match {
81
- case Some (value) ⇒ conv.convert[Props ](value)
82
- case None ⇒ NoVal
158
+ case Some (value) ⇒
159
+ conv.convert[Props ](value)
160
+
161
+ case None ⇒
162
+ NoVal
83
163
}
164
+
165
+ def getPropsEx (key : String ): Props = map.get(key) match {
166
+ case Some (value) ⇒
167
+ conv.convertEx[Props ](value)
168
+
169
+ case None ⇒
170
+ throw new IllegalArgumentException (" Unknown key %s" .format(key))
171
+ }
172
+
84
173
85
174
def getList (key : String , separatorRegex : String = " \\ s*,\\ s*" ) = map.get(key) match {
86
- case Some (value) ⇒ value.split(separatorRegex).toList
87
- case None ⇒ Nil
175
+ case Some (value) ⇒
176
+ value.split(separatorRegex).toList
177
+
178
+ case None ⇒
179
+ Nil
88
180
}
89
181
90
- def getTrimmedList (key : String , separatorRegex : String = " \\ s*,\\ s*" ): List [String ] =
182
+ def getTrimmedList (key : String , separatorRegex : String = " \\ s*,\\ s*" ): List [String ] = {
91
183
getList(key, separatorRegex).map(_.trim).filter(_.length > 0 )
184
+ }
92
185
93
186
override def equals (any : Any ) = any match {
94
- case props : Props if (props.getClass == this .getClass) ⇒ props.map == this .map
95
- case _ ⇒ false
187
+ case props : Props if (props.getClass == this .getClass) ⇒
188
+ props.map == this .map
189
+
190
+ case _ ⇒
191
+ false
96
192
}
97
193
98
194
def equalsProps (other : Props ): Boolean = other match {
99
- case null ⇒ false
100
- case _ ⇒ equalsMap(other.map)
195
+ case null ⇒
196
+ false
197
+
198
+ case _ ⇒
199
+ equalsMap(other.map)
101
200
}
102
201
103
202
def equalsMap (other : Map [String , String ]): Boolean = other match {
104
- case null ⇒ false
105
- case _ ⇒ other == this .map
203
+ case null ⇒
204
+ false
205
+
206
+ case _ ⇒
207
+ other == this .map
106
208
}
107
209
108
210
def toEnv : Env = {
0 commit comments