-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored suggestedType+guessTypeWithSuggestedAsUpperbound into Type…
…Suggestion, working on feedback
- Loading branch information
1 parent
42e2d67
commit dfaf46e
Showing
11 changed files
with
119 additions
and
73 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
39 changes: 39 additions & 0 deletions
39
core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/columns/TypeSuggestion.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,39 @@ | ||
package org.jetbrains.kotlinx.dataframe.columns | ||
|
||
import kotlin.reflect.KType | ||
|
||
/** | ||
* The suggestion of how to find a column type. | ||
* | ||
* The suggestion can either be: | ||
* | ||
* - [Infer] - {@include [Infer]} | ||
* - [InferWithUpperbound] - {@include [InferWithUpperbound]} | ||
* - [Use] - {@include [Use]} | ||
* | ||
* It can be either an [exact type][Use] or an [upper bound][InferWithUpperbound] of possible types | ||
* after which the library will infer the exact type. | ||
*/ | ||
public sealed interface TypeSuggestion { | ||
|
||
public companion object { | ||
|
||
/** Creates a new [TypeSuggestion] instance based on the given parameters. */ | ||
public fun create(suggestedType: KType?, guessType: Boolean): TypeSuggestion = | ||
when { | ||
suggestedType != null && guessType -> InferWithUpperbound(suggestedType) | ||
suggestedType != null && !guessType -> Use(suggestedType) | ||
suggestedType == null && guessType -> Infer | ||
else -> error("Cannot create TypeSuggestion with no suggested type and no guessing allowed.") | ||
} | ||
} | ||
|
||
/** The library will try to infer the type by checking all the values. */ | ||
public data object Infer : TypeSuggestion | ||
|
||
/** The library will infer the type by checking all the values taking a given upper bound into account. */ | ||
public data class InferWithUpperbound(val upperbound: KType) : TypeSuggestion | ||
|
||
/** The library will use the specified type without inference. */ | ||
public data class Use(val type: KType) : TypeSuggestion | ||
} |
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
Oops, something went wrong.