Adversaria
Adversaria is a tiny library which provides a few tools to make it easier to work with static annotations in Scala, by making them available through typeclass interfaces.
Features
- access all annotations on a type through a typeclass
- resolve a typeclass instance only if a type has an annotated field
- makes annotations more useful and accessible in Scala
- no macro code is required to use annotations
Availability
The current latest release of Adversaria is 0.4.0.
Getting Started
The nature of annotations in Scala is that they are very rarely the best solution for any task, but can be convenient in certain circumstances, and this small domain is where Adversaria aims to help.
Currently three use cases are supported:
- getting all the annotations applied to a particular type
- finding the parameter of a case class to which a particular annotation has been applied
- getting all the annotations applied to a particular case class field
The list of supported use cases may grow.
Examples
If we were to define the following annotations,
import scala.annotation.StaticAnnotation
final case class id() extends StaticAnnotation
final case class count(n: Int) extends StaticAnnotation
we could apply them to some case classes, such as,
@count(10)
case class Company(name: String)
case class Person(name: String, @id email: String)
Related Projects
The following Scala One libraries are dependencies of Adversaria:
No other Scala One libraries are dependents of Adversaria.
Status
Adversaria is classified as fledgling. Propensive defines the following five stability levels for open-source projects:
- embryonic: for experimental or demonstrative purposes only, without any guarantees of longevity
- fledgling: of proven utility, seeking contributions, but liable to significant redesigns
- maturescent: major design decisions broady settled, seeking probatory adoption and refinement
- dependable: production-ready, subject to controlled ongoing maintenance and enhancement; tagged as version
1.0
or later - adamantine: proven, reliable and production-ready, with no further breaking changes ever anticipated
Adversaria is designed to be small. Its entire source code currently consists of 92 lines of code.
Building
Adversaria can be built on Linux or Mac OS with Irk, by running the irk
script in the root directory:
./irk
This script will download irk
the first time it is run, start a daemon process, and run the build. Subsequent
invocations will be near-instantaneous.
Contributing
Contributors to Adversaria are welcome and encouraged. New contributors may like to look for issues marked .
We suggest that all contributors read the Contributing Guide to make the process of contributing to Adversaria easier.
Please do not contact project maintainers privately with questions. While it can be tempting to repsond to such questions, private answers cannot be shared with a wider audience, and it can result in duplication of effort.
Author
Adversaria was designed and developed by Jon Pretty, and commercial support and training is available from Propensive OÜ.
Name
Adversaria are miscellaneous collections of notes or annotations, after which the library is named.
License
Adversaria is copyright © 2019-22 Jon Pretty & Propensive OÜ, and is made available under the Apache 2.0 License.