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