-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for list component map (#8)
- Loading branch information
Showing
5 changed files
with
121 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
.../antelopesystem/crudframework/utils/component/componentmap/model/SingletonComponentMap.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.antelopesystem.crudframework.utils.component.componentmap.model | ||
|
||
class SingletonComponentMap<K, V>(private val originalMap: Map<K, Collection<V>>) : Map<K, V> { | ||
override val size: Int | ||
get() = originalMap.size | ||
|
||
override val values: Collection<V> | ||
get() = originalMap.values.map { it.first() } | ||
override val entries: Set<Map.Entry<K, V>> | ||
get() = originalMap.map { | ||
it.key to it.value.first() | ||
}.toMap().entries | ||
override val keys: Set<K> | ||
get() = originalMap.keys | ||
|
||
override fun containsKey(key: K): Boolean { | ||
return originalMap.containsKey(key) | ||
} | ||
|
||
override fun containsValue(value: V): Boolean { | ||
return originalMap.values.any { it.first() == value } | ||
} | ||
|
||
override fun get(key: K): V? { | ||
return originalMap[key]?.first() | ||
} | ||
|
||
override fun isEmpty(): Boolean { | ||
return originalMap.isEmpty() | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters