PageRenderTime 144ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/java/com/alibaba/fastjson/parser/deserializer/UUIDDeserializer.java

https://bitbucket.org/xiejuntao/xdesktop
Java | 27 lines | 19 code | 8 blank | 0 comment | 2 complexity | 02a905bed5f2e90236e87df56d59b8a7 MD5 | raw file
  1. package com.alibaba.fastjson.parser.deserializer;
  2. import java.lang.reflect.Type;
  3. import java.util.UUID;
  4. import com.alibaba.fastjson.parser.DefaultJSONParser;
  5. import com.alibaba.fastjson.parser.JSONToken;
  6. public class UUIDDeserializer implements ObjectDeserializer {
  7. public final static UUIDDeserializer instance = new UUIDDeserializer();
  8. @SuppressWarnings("unchecked")
  9. public <T> T deserialze(DefaultJSONParser parser, Type clazz, Object fieldName) {
  10. String name = (String) parser.parse();
  11. if (name == null) {
  12. return null;
  13. }
  14. return (T) UUID.fromString(name);
  15. }
  16. public int getFastMatchToken() {
  17. return JSONToken.LITERAL_STRING;
  18. }
  19. }