-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137033107
- Loading branch information
1 parent
840451a
commit 52e2335
Showing
1 changed file
with
41 additions
and
1 deletion.
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,3 +1,43 @@ | ||
# Extensions | ||
|
||
TODO | ||
|
||
AutoValue can be extended to implement new features for classes annotated with | ||
`@AutoValue`. | ||
|
||
## Using extensions | ||
|
||
Each extension is a class. If that class is on the `processorpath` when you | ||
compile your `@AutoValue` class, the extension can run. | ||
|
||
|
||
Some extensions are triggered by their own annotations, which you add to your | ||
class; others may be triggered in other ways. Consult the extension's | ||
documentation for usage instructions. | ||
|
||
## Writing an extension | ||
|
||
To add a feature, write a class that extends [`AutoValueExtension`], and put | ||
that class on the `processorpath` along with `AutoValueProcessor`. | ||
|
||
`AutoValueExtension` uses the [`ServiceLoader`] mechanism, which means: | ||
|
||
* Your class must be public and have a public no-argument constructor. | ||
* Its fully-qualified name must appear in a file called | ||
`META-INF/services/com.google.auto.value.extension.AutoValueExtension` in a | ||
JAR that is on the compiler's `classpath` or `processorpath`. | ||
|
||
You can use [AutoService] to make implementing the `ServiceLoader` pattern easy. | ||
|
||
Without extensions, AutoValue generates a subclass of the `@AutoValue` class. | ||
Extensions can work by generating a chain of subclasses, each of which alters | ||
behavior by overriding or implementing new methods. | ||
|
||
## TODO | ||
|
||
* How to distribute extensions. | ||
* List of known extensions. | ||
|
||
[AutoService]: https://github.com/google/auto/tree/master/service | ||
[`AutoValueExtension`]: https://github.com/google/auto/blob/master/value/src/main/java/com/google/auto/value/extension/AutoValueExtension.java | ||
[`ServiceLoader`]: http://docs.oracle.com/javase/7/docs/api/java/util/ServiceLoader.html | ||
|