@Override public void write(JsonWriter out, UserRole value) throws IOException { if (value == null) { out.nullValue(); } else { out.value(value.getValue()); } }
@Override public UserRole read(JsonReader in) throws IOException { JsonToken jsonToken = in.peek(); if (jsonToken == JsonToken.NULL) { in.nextNull(); return null; } else { try { return UserRole.values()[in.nextInt()]; } catch (RuntimeException e) { throw new IOException(Messages.INVALID_USER_ROLE, e); } } }