-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from cph-cachet/develop
Release 1.0.0-alpha.36
- Loading branch information
Showing
91 changed files
with
2,573 additions
and
222 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
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
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
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
15 changes: 0 additions & 15 deletions
15
carp.common/src/commonMain/kotlin/dk/cachet/carp/common/application/EnumObjectList.kt
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
carp.common/src/commonMain/kotlin/dk/cachet/carp/common/application/EnumObjectMap.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 dk.cachet.carp.common.application | ||
|
||
|
||
/** | ||
* A helper class to construct iterable objects which hold [V] member definitions indexed on [K]. | ||
* This is similar to an enum, but removes the need for an intermediate enum type and generic type parameters are retained per member. | ||
* | ||
* Extend from this class as an object and assign members as follows: `val MEMBER = add( SomeMember() )`. | ||
*/ | ||
open class EnumObjectMap<K, V> private constructor( | ||
private val map: MutableMap<K, V>, | ||
val keyOf: (V) -> K | ||
) : Map<K, V> by map | ||
{ | ||
constructor( | ||
/** | ||
* Specifies how to retrieve the key for the specified element. | ||
*/ | ||
keyOf: (V) -> K | ||
) : this( mutableMapOf(), keyOf ) | ||
|
||
/** | ||
* Add an element using the key which is extracted from [item] using [keyOf]. | ||
* | ||
* @throws IllegalArgumentException in case the extracted from [item] is already present in this map. | ||
*/ | ||
protected fun <TAdd : V> add( item: TAdd ): TAdd = item.also { | ||
val key = keyOf( it ) | ||
require( !map.contains( key ) ) { "An item with the same key is already present." } | ||
|
||
map[ key ] = it | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
carp.common/src/commonMain/kotlin/dk/cachet/carp/common/application/RangeExtensions.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,32 @@ | ||
package dk.cachet.carp.common.application | ||
|
||
|
||
/** | ||
* Returns the intersection of this range with the specified [range], or an empty range if there is no intersection. | ||
*/ | ||
fun CharRange.intersect( range: CharRange ): CharRange = | ||
intersectRange( range ).let { CharRange( it.start, it.endInclusive ) } | ||
|
||
/** | ||
* Returns the intersection of this range with the specified [range], or an empty range if there is no intersection. | ||
*/ | ||
fun IntRange.intersect( range: IntRange ): IntRange = | ||
intersectRange( range ).let { IntRange( it.start, it.endInclusive ) } | ||
|
||
/** | ||
* Returns the intersection of this range with the specified [range], or an empty range if there is no intersection. | ||
*/ | ||
fun LongRange.intersect( range: LongRange ): LongRange = | ||
intersectRange( range ).let { LongRange( it.start, it.endInclusive ) } | ||
|
||
|
||
/** | ||
* Returns the intersection of this range with the specified [range], or an empty range if there is no intersection. | ||
*/ | ||
private fun <T : Comparable<T>> ClosedRange<T>.intersectRange( range: ClosedRange<T> ): ClosedRange<T> | ||
{ | ||
val startRange = maxOf( start, range.start ) | ||
val endRange = minOf( endInclusive, range.endInclusive ) | ||
|
||
return startRange..endRange | ||
} |
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
7 changes: 4 additions & 3 deletions
7
.../application/data/DataTypeMetaDataList.kt → ...n/application/data/DataTypeMetaDataMap.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
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
Oops, something went wrong.