@TypeConverter public SortPhotoEntity intToSortPhotoEntity(int value) { SortPhotoEntity result = null; if (value == SortPhotoEntity.LATEST.getCode()) { result = SortPhotoEntity.LATEST; } if (value == SortPhotoEntity.POPULAR.getCode()) { result = SortPhotoEntity.POPULAR; } if (value == SortPhotoEntity.OLDEST.getCode()) { result = SortPhotoEntity.OLDEST; } return result; }
@TypeConverter public static List<Integer> stringToIntList(String data) { if (data == null) { return Collections.emptyList(); } return StringUtil.splitToIntList(data); }
@TypeConverter public static String stringToIntList(Date date) { if (date != null) { return new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH).format(date); } return new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH).format(new Date()); }
@TypeConverter public static Date intListToString(String date) { if (!date.equals("")) { try { return new SimpleDateFormat(DATE_FORMAT, Locale.ENGLISH).parse(date); } catch (ParseException e) { e.printStackTrace(); return new Date(); } } return new Date(); }
@TypeConverter public static State toState(String state) { if (TextUtils.isEmpty(state)) { return State.LOBBY; } return State.valueOf(state); }
@TypeConverter public CalendarDate fromString(String value) { if(value == null) { return null; } return CalendarDate.decodeFromString(value); }
@TypeConverter public String toString(CalendarDate date) { if(date == null) { return null; } return date.encodeToString(); }
@TypeConverter public Integer toInt(Gender value) { if(value == null) { return null; } return value.encodeToInt(); }
@TypeConverter public Long dateToTimestamp(Date date) { if (date == null) { return null; } else { return date.getTime(); } }
@TypeConverter public static Date toDate(final Long value) { return value == null ? null : new Date(value); }
@TypeConverter public static String toString(String[] images) { StringBuilder stringBuilder = new StringBuilder(); for (String image : images) { stringBuilder.append(image).append(","); } stringBuilder.deleteCharAt(stringBuilder.length() - 1); return stringBuilder.toString(); }
@TypeConverter public static String toString(State state) { if (state == null) { return null; } return state.toString(); }
@TypeConverter public static String tagsToString(List<Tag> tags) { StringBuilder buffer = new StringBuilder(); for (Tag tag : tags) { buffer.append(tag.getId()).append(":").append(tag.getName()).append(";"); } return buffer.toString(); }
@TypeConverter public static String intListToString(List<Integer> ints) { return StringUtil.joinIntoString(ints); }
@TypeConverter public static Project projectFromId(String id) { return id == null ? null : new Project(id); }
@TypeConverter public static User userFromUserId(String id) { return id == null ? null : new User(id); }
@TypeConverter public static Date fromTimestamp(Long value) { return value == null ? null : new Date(value); }
@TypeConverter public static Long dateToTimestamp(Date date) { return date == null ? null : date.getTime(); }
@TypeConverter public static String fromEnum(EnumUserStatus value) { // TODO: Handle null values return value.name(); }
@TypeConverter public static Long toLong(Date value) { return value == null ? null : value.getTime(); }
@TypeConverter public static Long fromDate(final Date date) { return date == null ? null : date.getTime(); }
@TypeConverter public static String fromFile(final File value) { return value == null ? null : value.getAbsolutePath(); }
@TypeConverter public static File toFile(final String path) { return path == null ? null : new File(path); }
@TypeConverter public static String fromCategory(final Category value) { return value == null ? null : value.name(); }
@TypeConverter public static Category toCategory(final String name) { return name == null ? null : Category.valueOf(name); }
@TypeConverter public static Attachment.Type toAttachmentType(final String name) { return name == null ? null : Attachment.Type.valueOf(name); }
@TypeConverter public static String taskToTaskId(Task task) { return task == null ? null : task.getId(); }
@TypeConverter public static String fromAttachmentType(final Attachment.Type value) { return value == null ? null : value.name(); }