Search in sources :

Example 6 with TypeConverter

use of android.arch.persistence.room.TypeConverter in project bugzy by cpunq.

the class BugzyTypeConverters method caseEventListFromString.

@TypeConverter
public static List<CaseEvent> caseEventListFromString(String value) {
    Type listType = new TypeToken<List<CaseEvent>>() {
    }.getType();
    List<CaseEvent> events = sGson.fromJson(value, listType);
    if (events != null) {
        Collections.sort(events, ((caseEvent, t1) -> Long.compare(t1.getDate().getTime(), caseEvent.getDate().getTime())));
    }
    return events;
}
Also used : CaseEvent(com.bluestacks.bugzy.data.model.CaseEvent) FieldNamingPolicy(com.google.gson.FieldNamingPolicy) List(java.util.List) TypeToken(com.google.gson.reflect.TypeToken) Type(java.lang.reflect.Type) Gson(com.google.gson.Gson) Date(java.util.Date) TypeConverter(android.arch.persistence.room.TypeConverter) Collections(java.util.Collections) GsonBuilder(com.google.gson.GsonBuilder) ArrayList(java.util.ArrayList) Type(java.lang.reflect.Type) List(java.util.List) ArrayList(java.util.ArrayList) CaseEvent(com.bluestacks.bugzy.data.model.CaseEvent) TypeConverter(android.arch.persistence.room.TypeConverter)

Aggregations

TypeConverter (android.arch.persistence.room.TypeConverter)6 Gson (com.google.gson.Gson)6 CaseEvent (com.bluestacks.bugzy.data.model.CaseEvent)1 FieldNamingPolicy (com.google.gson.FieldNamingPolicy)1 GsonBuilder (com.google.gson.GsonBuilder)1 TypeToken (com.google.gson.reflect.TypeToken)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Date (java.util.Date)1 List (java.util.List)1