Skip to content

Commit

Permalink
add more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixAnthonisen committed Nov 12, 2024
1 parent d754a8e commit 6ada97c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ $ git submodule add https://github.com/bldl/java-variance

## Usage

### Annotations

There are currently three annotations provided by this project: MyVariance, Covariant and Contravariant. With these you are able to annotate type parameters for classes in order to

#### MyVariance

MyVariance is the most customizable one, and allows you to experiment with different types of variance. With this one there are several parameters you can provide to specify what variance rules should apply:

| Parameter | Description | Possible values |
| ---------- | ----------------------------------------- | ----------------------------------- |
| `variance` | Specifies which variance to use | COVARIANT, CONTRAVARIANT, INVARIANT |
| `depth` | How deep subtyping goes | Integer value ≥ 0 |
| `strict` | Whether strict checks should be performed | `true`, `false` |

#### Covariant

Covariant is a specific instance of MyVariance. It's intended to inline with the semantics of traditional covariance. It acts as MyVariance with `variance` set to `COVARIANT`, `depth` as infinite and `strict` to `true`.

#### Contravariant

Contravariant, similarly to Covariant, aims to inline with the semantics of traditional contravariance. It acts as MyVariance with `variance` set to `CONTRAVARIANT`, `depth` as infinite and `strict` to `true`.

### Subsection

## Contributing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* }
* </pre>
*
* @see VarianceType
* @see {@link VarianceType}
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE_PARAMETER)
Expand Down

0 comments on commit 6ada97c

Please sign in to comment.