Changeset 15951 in josm


Ignore:
Timestamp:
2020-02-28T00:58:00+01:00 (5 years ago)
Author:
simon04
Message:

Simplify OsmUtils.isTrue/isFalse/isReversed (fix NPE)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java

    r15950 r15951  
    8383     */
    8484    public static boolean isReversed(String value) {
     85        if (value == null) {
     86            return false;
     87        }
    8588        switch (value) {
    8689            case "reverse":
     
    98101     */
    99102    public static boolean isTrue(String value) {
     103        if (value == null) {
     104            return false;
     105        }
    100106        switch (value) {
    101107            case "true":
     
    115121     */
    116122    public static boolean isFalse(String value) {
     123        if (value == null) {
     124            return false;
     125        }
    117126        switch (value) {
    118127            case "false":
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmUtilsTest.java

    r15950 r15951  
    7575    @Test
    7676    public void testTrueFalse() {
     77        assertFalse(OsmUtils.isTrue(null));
     78        assertFalse(OsmUtils.isFalse(null));
     79        assertNull(OsmUtils.getOsmBoolean(null));
    7780        assertTrue(OsmUtils.isTrue("yes"));
    7881        assertFalse(OsmUtils.isFalse("yes"));
Note: See TracChangeset for help on using the changeset viewer.