Created
July 31, 2021 01:10
-
-
Save DamianReeves/897ace5f8996f56740eebd3d8acd2fd6 to your computer and use it in GitHub Desktop.
Field Properties
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
package datadictionary | |
import datadictionary.Field.Modifier | |
type AnyField = Field[?, Nothing, Nothing] | |
type AnyFieldHavingKeyOf[K <: Field.FieldKey] = Field[K, Nothing, Nothing] | |
final case class Field[Key <: Field.FieldKey, +A, +Attribs](key: Key) extends Serializable: | |
def asConstant(using Attribs <:< Modifier.Assignable) = ??? | |
override def toString: String = key | |
override def hashCode(): Int = key.hashCode() | |
object Field: | |
type FieldKey = String & Singleton | |
def constant[K <: FieldKey](key: K): ConstantPartiallyApplied[K] = ConstantPartiallyApplied(key) | |
def string[K <: FieldKey](key: K): Field[K, String, Modifier.Assignable] = | |
Field[K, String, Modifier.Assignable](key) | |
object Modifier: | |
type Assignable | |
type ReadOnly | |
type Constant <: ReadOnly | |
class ConstantPartiallyApplied[K <: FieldKey](key: K) extends AnyVal: | |
def apply[A]: Field[K, A, Modifier.Constant] = as[A] | |
def as[A]: Field[K, A, Modifier.Constant] = Field[K, A, Modifier.Constant](key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment