diff options
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/data/CidrAddress.kt')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/data/CidrAddress.kt | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/data/CidrAddress.kt b/app/src/main/java/org/pacien/tincapp/data/CidrAddress.kt index 273b5a2..f3a7ea8 100644 --- a/app/src/main/java/org/pacien/tincapp/data/CidrAddress.kt +++ b/app/src/main/java/org/pacien/tincapp/data/CidrAddress.kt | |||
@@ -7,18 +7,18 @@ import org.apache.commons.configuration2.ex.ConversionException | |||
7 | */ | 7 | */ |
8 | data class CidrAddress(val address: String, val prefix: Int) { | 8 | data class CidrAddress(val address: String, val prefix: Int) { |
9 | 9 | ||
10 | companion object { | 10 | companion object { |
11 | 11 | ||
12 | private val SEPARATOR = "/" | 12 | private val SEPARATOR = "/" |
13 | |||
14 | fun fromSlashSeparated(s: String) = try { | ||
15 | CidrAddress(s.substringBefore(SEPARATOR), Integer.parseInt(s.substringAfter(SEPARATOR))) | ||
16 | } catch (e: Exception) { | ||
17 | throw ConversionException(e.message, e) | ||
18 | } | ||
19 | 13 | ||
14 | fun fromSlashSeparated(s: String) = try { | ||
15 | CidrAddress(s.substringBefore(SEPARATOR), Integer.parseInt(s.substringAfter(SEPARATOR))) | ||
16 | } catch (e: Exception) { | ||
17 | throw ConversionException(e.message, e) | ||
20 | } | 18 | } |
21 | 19 | ||
22 | fun toSlashSeparated() = address + SEPARATOR + prefix | 20 | } |
21 | |||
22 | fun toSlashSeparated() = address + SEPARATOR + prefix | ||
23 | 23 | ||
24 | } | 24 | } |