https://github.com/joht/alias
alias names for java types
https://github.com/joht/alias
alias aliases annotation-processor discoverability eventsourcing json serializer upcasting
Last synced: 2 months ago
JSON representation
alias names for java types
- Host: GitHub
- URL: https://github.com/joht/alias
- Owner: JohT
- License: apache-2.0
- Created: 2019-04-04T19:58:45.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-16T04:36:00.000Z (8 months ago)
- Last Synced: 2024-10-17T19:24:35.562Z (8 months ago)
- Topics: alias, aliases, annotation-processor, discoverability, eventsourcing, json, serializer, upcasting
- Language: Java
- Homepage:
- Size: 1 MB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Security: SECURITY.md
Awesome Lists containing this project
README
[](https://opensource.org/licenses/Apache-2.0)
[](https://maven-badges.herokuapp.com/maven-central/io.github.joht.alias/type-alias/)
# aliasJava identifies types by their class name.
The class name heavily depends on implementation details (e.g. where the class is located).
Finding the right name and right place may change during development.
As soon as the class name is used to identify e.g. an deserialized object before reconstructing it,
a changed class name leads to a runtime exception.**type-alias** enables naming those types distinctly besides their class name.
This is done at compile time (no runtime dependencies) by using the annotation `@TypeAlias`.
The result is a generated file (e.g. ResourceBundle or Properties),
that contains a register of all aliases and their current type name.**type-alias** only depends on Java itself and is not needed during runtime.
The annotations are not present in byte code (not accessible via reflection),
The generated alias name register is a standard Java file (ResourceBundle or Property-File).### Quickstart
Include the following compile-time-only dependency.
It provides the annotations `@TypeAlias`, `@TypeAliases` to attach alias names,
`@TypeAliasGeneratedFile` for customization and the java annotation processing based file generator,
that generates (by default) the ResourceBundle `TypeAlias.java` inside the default package containing all aliases.```xml
io.github.joht.alias
type-alias
2.0.0
provided
true```
### Building this project
Install maven and use `mvn install` to build this project, run all tests including the integration tests and copy the resulting artifacts into the local maven repository. A list of the most important commands can be found in [COMMANDS.md](COMMANDS.md).### Changes
All changes are listed in [CHANGELOG.md](./CHANGELOG.md). The file is generated automatically during "generate-resources" build phase based on merged pull requests and their tags.#### Breaking changes in Version 2.x
- `type-alias-jsonb-typereference` had been migrated to Java 11
- `type-alias-example` had been migrated to Java 11
- `type-alias-axon-serializer-integration-test` will no longer be published to maven central### Contents
- [type-alias](https://github.com/JohT/alias/tree/master/type-alias)
contains the main module with the java annotation processing based file generator.
- [type-alias-example](https://github.com/JohT/alias/tree/master/type-alias-example)
shows, how to use and customize "type-alias" code generation.
- [type-alias-axon-serializer](https://github.com/JohT/alias/tree/master/type-alias-axon-serializer)
shows, how to enhance axon serializer to use aliases.
- [type-alias-axon-serializer-integration-test](https://github.com/JohT/alias/tree/master/type-alias-axon-serializer-integration-test)
shows, how to configure axon serializer to use aliases.