package com.eltech.soceltech.data.model.converters;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.greenrobot.greendao.converter.PropertyConverter;

import java.util.List;
import java.util.Set;

public class ListStringConverter implements PropertyConverter<List<String>, String> {

	@Override
	public List<String> convertToEntityProperty(String databaseValue) {
		if (databaseValue == null) {
			return null;
		} else {
			return new Gson().fromJson(databaseValue, new TypeToken<List<String>>() {}.getType());
		}
	}

	@Override
	public String convertToDatabaseValue(List<String> entityProperty) {
		if (entityProperty == null) {
			return null;
		} else {
			return new Gson().toJson(entityProperty);
		}
	}
}