de.pewpewproject.lasertag.common.util.ConverterUtil   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A stringToPrimitiveType(String) 0 8 2
1
package de.pewpewproject.lasertag.common.util;
2
3
/**
4
 * Utils for type conversion
5
 *
6
 * @author Étienne Muser
7
 */
8
public class ConverterUtil {
9
    /**
10
     * Converts a string to the correct primitive type.
11
     * Currently only supports long and boolean
12
     * @param value The string to convert
13
     * @return The converted primitive type
14
     */
15
    public static Object stringToPrimitiveType(String value) {
16
        // Try to convert to int
17
        try {
18
            return Long.parseLong(value);
19
        } catch (NumberFormatException ignored) {}
20
21
        // Convert to boolean
22
        return Boolean.parseBoolean(value);
23
    }
24
}
25