/src/main/java/com/alibaba/fastjson/parser/deserializer/UUIDDeserializer.java
Java | 27 lines | 19 code | 8 blank | 0 comment | 2 complexity | 02a905bed5f2e90236e87df56d59b8a7 MD5 | raw file
- package com.alibaba.fastjson.parser.deserializer;
- import java.lang.reflect.Type;
- import java.util.UUID;
- import com.alibaba.fastjson.parser.DefaultJSONParser;
- import com.alibaba.fastjson.parser.JSONToken;
- public class UUIDDeserializer implements ObjectDeserializer {
- public final static UUIDDeserializer instance = new UUIDDeserializer();
- @SuppressWarnings("unchecked")
- public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
-
- String name = (String) parser.parse();
-
- if (name == null) {
- return null;
- }
-
- return (T) UUID.fromString(name);
- }
- public int getFastMatchToken() {
- return JSONToken.LITERAL_STRING;
- }
- }