Skip to content

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

License

Notifications You must be signed in to change notification settings

CarmJos/EasyAnnotation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 ___                _                 _        _   _          
| __|__ _ ____  _  /_\  _ _  _ _  ___| |_ __ _| |_(_)___ _ _  
| _|/ _` (_-< || |/ _ \| ' \| ' \/ _ \  _/ _` |  _| / _ \ ' \ 
|___\__,_/__/\_, /_/ \_\_||_|_||_\___/\__\__,_|\__|_\___/_||_|
             |__/                                             

README LANGUAGES [ English | 中文 ]

EasyAnnotation

version License workflow CodeFactor CodeSize

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.

Development

For the latest JavaDoc release, CLICK HERE.

Code Samples

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);
    }
}

Dependencies

Maven Dependency

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>

Gradle Dependency

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]"
}

Support and Donation

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.

Open Source License

This project's source code is licensed under The MIT License.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages