Skip to content

Commit 98c2ec0

Browse files
committed
Moved setter/getter for various object types in their own file
1 parent e141b82 commit 98c2ec0

File tree

2 files changed

+47
-17
lines changed

2 files changed

+47
-17
lines changed

objects.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* This file is part of PropertiesMap library.
3+
*
4+
* Copyright 2018 Arduino AG (http://www.arduino.cc/)
5+
*
6+
* PropertiesMap library is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*
20+
* As a special exception, you may use this file as part of a free software
21+
* library without restriction. Specifically, if other files instantiate
22+
* templates or use macros or inline functions from this file, or you compile
23+
* this file and link it with other files to produce an executable, this
24+
* file does not by itself cause the resulting executable to be covered by
25+
* the GNU General Public License. This exception does not however
26+
* invalidate any other reasons why the executable file might be covered by
27+
* the GNU General Public License.
28+
*/
29+
30+
package properties
31+
32+
// GetBoolean returns true if the map contains the specified key and the value
33+
// equals to the string "true", in any other case returns false.
34+
func (m Map) GetBoolean(key string) bool {
35+
value, ok := m[key]
36+
return ok && value == "true"
37+
}
38+
39+
// SetBoolean sets the specified key to the string "true" of "false" if the value
40+
// is respectively true or false.
41+
func (m Map) SetBoolean(key string, value bool) {
42+
if value {
43+
m[key] = "true"
44+
} else {
45+
m[key] = "false"
46+
}
47+
}

properties.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -293,23 +293,6 @@ func (m Map) Equals(other Map) bool {
293293
return reflect.DeepEqual(m, other)
294294
}
295295

296-
// GetBoolean returns true if the map contains the specified key and the value
297-
// equals to the string "true", in any other case returns false.
298-
func (m Map) GetBoolean(key string) bool {
299-
value, ok := m[key]
300-
return ok && value == "true"
301-
}
302-
303-
// SetBoolean sets the specified key to the string "true" of "false" if the value
304-
// is respectively true or false.
305-
func (m Map) SetBoolean(key string, value bool) {
306-
if value {
307-
m[key] = "true"
308-
} else {
309-
m[key] = "false"
310-
}
311-
}
312-
313296
// MergeMapsOfProperties merge the map-of-Maps (obtained from the method FirstLevelOf()) into the
314297
// target map-of-Maps.
315298
func MergeMapsOfProperties(target map[string]Map, sources ...map[string]Map) map[string]Map {

0 commit comments

Comments
 (0)