Skip to content

JohT/alias

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,201 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alias

License Maven Central

Java 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.

<dependency>
  <groupId>io.github.joht.alias</groupId>
  <artifactId>type-alias</artifactId>
  <version>2.0.0</version>
  <scope>provided</scope>
  <optional>true</optional>
</dependency>

Building this project

Install maven and use mvn install to build this project and copy the resulting artifacts into the local maven repository. Integration-test modules are not part of the root reactor and must be built explicitly. A list of the most important commands can be found in COMMANDS.md.

Changes

All changes are listed in CHANGELOG.md. The file is generated during the generate-sources phase when the releases Maven profile is activated. To regenerate it locally with PR titles, set the GITHUB_CHANGELOG_TOKEN environment variable:

GITHUB_CHANGELOG_TOKEN=<your-token> mvn clean verify -Preleases

Without the token, only dependency updates (extracted from commit messages) will include titles; feature PRs will show only issue numbers.

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