-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
25 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,28 @@ | ||
# Scala Type-Safe Annotation Plugin | ||
[![License: MIT](http://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) | ||
[![Circle CI](https://circleci.com/gh/tkqubo/scala-typed-annotation-plugin.svg?style=svg)](https://circleci.com/gh/tkqubo/scala-typed-annotation-plugin) | ||
[![Test Coverage](https://codeclimate.com/github/tkqubo/scala-typed-annotation-plugin/badges/coverage.svg)](https://codeclimate.com/github/tkqubo/scala-typed-annotation-plugin/coverage) | ||
[![Issue Count](https://codeclimate.com/github/tkqubo/scala-typed-annotation-plugin/badges/issue_count.svg)](https://codeclimate.com/github/tkqubo/scala-typed-annotation-plugin) | ||
[![Circle CI](https://img.shields.io/circleci/project/tkqubo/scala-typed-annotation-plugin/master.svg)](https://circleci.com/gh/tkqubo/scala-typed-annotation-plugin) | ||
[![Coverage Status](https://coveralls.io/repos/tkqubo/scala-typed-annotation-plugin/badge.svg?branch=master&service=github)](https://coveralls.io/github/tkqubo/scala-typed-annotation-plugin?branch=master) | ||
|
||
Your annotations now become type-safe | ||
|
||
# Usage | ||
|
||
1. Annotate your annotation with `TypedAnnotation`, providing the type you want to endorse on the target annotation. | ||
|
||
``` | ||
@TypedAnnotation(classOf[Long]) | ||
class max(val value: Long) extends StaticAnnotation | ||
``` | ||
|
||
2. Then you can get the compilation error when you put that annotation on a member variable with a wrong type | ||
|
||
```scala | ||
object Test { | ||
@max(255) | ||
var value: String = null // compilation error, because Long and String doesn't match | ||
} | ||
``` | ||
|
||
3. That's it! | ||
|
||
|
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 |
---|---|---|
|
@@ -45,3 +45,4 @@ object TypedAnnotationPluginTest { | |
@childNamed("child") | ||
var child: Child = null | ||
} | ||
|