Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions libs/model/src/main/kotlin/de/cyface/model/osm/MapTag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/
package de.cyface.model.osm

import org.apache.commons.lang3.Validate
import java.util.Objects

/**
Expand All @@ -27,14 +26,7 @@ import java.util.Objects
* @author Armin Schnabel
* @property key The key of the OSM attribute
*/
abstract class MapTag(key: String) {
@JvmField
val key: String

init {
Validate.notNull(key)
this.key = key
}
abstract class MapTag(val key: String) {

override fun equals(other: Any?): Boolean {
if (this === other) return true
Expand Down
13 changes: 6 additions & 7 deletions libs/model/src/main/kotlin/de/cyface/model/osm/OsmTag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package de.cyface.model.osm

import org.apache.commons.lang3.Validate

/**
* Represents a single key,value paired Open Street Map (OSM) attribute.
*
Expand All @@ -28,9 +26,12 @@ import org.apache.commons.lang3.Validate
* @property value The value of the OSM attribute
*/
class OsmTag(key: String?, val value: Any) : MapTag(key!!) {

// Before other types were injected by accident, like `TextNode`
init {
// Before other types were injected by accident, like `TextNode`
Validate.isTrue(value is String || value is Double || value is Int)
require(value is String || value is Double || value is Int) {
"Invalid value type for OsmTag: ${value::class}"
}
}

override fun equals(other: Any?): Boolean {
Expand All @@ -42,9 +43,7 @@ class OsmTag(key: String?, val value: Any) : MapTag(key!!) {
}

override fun hashCode(): Int {
var result = super.hashCode()
result = 31 * result + value.hashCode()
return result
return 31 * super.hashCode() + value.hashCode()
}

override fun toString(): String {
Expand Down