Skip to content

Java annotation processor for generating dynamic enum methods

License

Notifications You must be signed in to change notification settings

altyndev/dynamic-enum-processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dynamic Enum Processor

Java annotation processor that automatically generates utility methods for enum types.

Features

  • Automatically generates is* methods for enum constants
  • Customizable method prefix
  • Zero runtime dependencies
  • Java 17+ support

Usage

Add the dependency to your project:

<dependency>
    <groupId>io.github.altyndev</groupId>
    <artifactId>dynamic-enum-processor</artifactId>
    <version>1.0.0</version>
</dependency>

Annotate your enum:

@DynamicEnum
public enum Role {
    ADMIN,
    USER,
    GUEST
}

The processor will generate a utility class:

public class RoleMethods {
    public static boolean isAdmin(Role value) {
        return value == Role.ADMIN;
    }

    public static boolean isUser(Role value) {
        return value == Role.USER;
    }

    public static boolean isGuest(Role value) {
        return value == Role.GUEST;
    }
}

Customization

You can customize the method prefix:

@DynamicEnum(methodPrefix = "has")
public enum Permission {
    READ,
    WRITE,
    EXECUTE
}

Building

mvn clean install

Publishing to Maven Central

  1. Create a Sonatype OSSRH account
  2. Set up GPG key
  3. Configure Maven settings.xml
  4. Run:
mvn clean deploy

License

MIT License

About

Java annotation processor for generating dynamic enum methods

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages