___ _ _ _ _
| __|__ _ ____ _ /_\ _ _ _ _ ___| |_ __ _| |_(_)___ _ _
| _|/ _` (_-< || |/ _ \| ' \| ' \/ _ \ _/ _` | _| / _ \ ' \
|___\__,_/__/\_, /_/ \_\_||_|_||_\___/\__\__,_|\__|_\___/_||_|
|__/
README LANGUAGES [ English | 中文 ]
Easy (to use) Annotations!
A lightweight, easy-to-use annotation load library in Java, which can use the data values in the annotations in a simple, friendly and expandable way.
For the latest JavaDoc release, CLICK HERE.
public interface DemoMetas {
/**
* Meta descriptions
*/
AnnotatedMetaType<DemoAnnotation, String> SAYING = AnnotatedMetaType.of(
DemoAnnotation.class, DemoAnnotation::value
);
AnnotatedMetaType<DemoAnnotation, Boolean> SUCCESS = AnnotatedMetaType.of(
DemoAnnotation.class, DemoAnnotation::success
);
AnnotatedMetaType<DemoAnnotation, Boolean> ANNOTATED = AnnotatedMetaType.of(
DemoAnnotation.class, (a) -> true
);
}
public class Sample {
public static void main(String[] args) {
// Create a loader
AnnotatedMetaLoader loader = AnnotatedMetaLoader.of(
DemoMetas.ANNOTATED, DemoMetas.SAYING, DemoMetas.SUCCESS
);
// Load from a field
Field field = AnnotationTest.class.getField("SOME_FIELD");
AnnotatedMetaHolder fieldMeta = loader.load(field);
boolean annotated = fieldMeta.get(DemoMetas.ANNOTATED);
// Load from a class
AnnotatedMetaHolder classMeta = loader.load(AnnotationTest.class);
String saying = classMeta.get(DemoMetas.SAYING);
}
}
Remote Repository Configuration
<project>
<repositories>
<repository>
<!-- Using Maven Central Repository for secure and stable updates, though synchronization might be needed. -->
<id>maven</id>
<name>Maven Central</name>
<url>https://repo1.maven.org/maven2</url>
</repository>
<repository>
<!-- Using GitHub dependencies for real-time updates, configure required (recommended). -->
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/CarmJos/EasyAnnotation</url>
</repository>
</repositories>
</project>
Generic Native Dependency
<project>
<dependencies>
<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>easyannotation</artifactId>
<version>[LATEST RELEASE]</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Remote Repository Configuration
repositories {
// Using Maven Central Repository for secure and stable updates, though synchronization might be needed.
mavenCentral()
// Using GitHub dependencies for real-time updates, configure required (recommended).
maven { url 'https://maven.pkg.github.com/CarmJos/EasyAnnotation' }
}
Generic Native Dependency
dependencies {
api "cc.carm.lib:easyannotation:[LATEST RELEASE]"
}
If you appreciate this plugin, consider supporting me with a donation!
Thank you for supporting open-source projects!
Many thanks to Jetbrains for kindly providing a license for us to work on this and other open-source projects.
This project's source code is licensed under The MIT License.