-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Common tags #549
Common tags #549
Conversation
Rename few files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small observations, nothing particularly significant.
val encode: (T) -> String?, | ||
val decode: (String) -> T?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth providing defaults for encode and decode as { it }
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this possible without knowing the type T?
Description
Introduces a
CommonTag
class to simplify and harmonise Styx object tags API. Now each Tag will be represented as a CommonTag instance, with providedname
,encode
anddecode
functions.This imposes a common format:
name = tag-value
.Each tag is associated with value type
T
. Theencode
anddecode
functions convert between values ofT
and encoded tag value strings.All common tag operations, like creating, searching, matching, and removing tags are now implemented as higher order functions in the common base class.
Alternative API
Some of the common functions could be implemented as Kotlin extension methods. Which method do you prefer? Let me know and we can shape the code accordingly.
An alternative to CommonTags find method would be:
Similarly, an alternative to
match
would be:An alternative to
valueOf
method would be: