+10
-1
@@ -25,7 +25,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* JwtEnum
|
||||
* This annotation marks the enum field declared in payload class will be
|
||||
* handled as basic data types in {@link TokenDataType}.
|
||||
*
|
||||
* @author Zihlu Wang
|
||||
*/
|
||||
@@ -33,8 +34,16 @@ import java.lang.annotation.Target;
|
||||
@Target({ElementType.FIELD})
|
||||
public @interface TokenEnum {
|
||||
|
||||
/**
|
||||
* The name of the field of the base data corresponding to the
|
||||
* enumeration data.
|
||||
*/
|
||||
String propertyName();
|
||||
|
||||
/**
|
||||
* The attribute {@code dataType} specifies what base data type to treat
|
||||
* this enum as.
|
||||
*/
|
||||
TokenDataType dataType();
|
||||
|
||||
}
|
||||
|
||||
+27
-1
@@ -20,21 +20,47 @@ package cn.org.codecrafters.simplejwt.constants;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* TokenDataType
|
||||
* The base data types used to process enum data.
|
||||
*
|
||||
* @author Zihlu Wang
|
||||
*/
|
||||
@Getter
|
||||
public enum TokenDataType {
|
||||
|
||||
/**
|
||||
* Marks enumeration being processed as Boolean.
|
||||
*/
|
||||
BOOLEAN(Boolean.class),
|
||||
|
||||
/**
|
||||
* Marks enumeration being processed as Double.
|
||||
*/
|
||||
DOUBLE(Long.class),
|
||||
|
||||
/**
|
||||
* Marks enumeration being processed as Float.
|
||||
*/
|
||||
FLOAT(Float.class),
|
||||
|
||||
/**
|
||||
* Marks enumeration being processed as Integer.
|
||||
*/
|
||||
INTEGER(Integer.class),
|
||||
|
||||
/**
|
||||
* Marks enumeration being processed as Long.
|
||||
*/
|
||||
LONG(Long.class),
|
||||
|
||||
/**
|
||||
* Marks enumeration being processed as String.
|
||||
*/
|
||||
STRING(String.class),
|
||||
;
|
||||
|
||||
/**
|
||||
* The mapped class to this mark.
|
||||
*/
|
||||
private final Class<?> mappedClass;
|
||||
|
||||
TokenDataType(Class<?> mappedClass) {
|
||||
|
||||
Reference in New Issue
Block a user