io.objectbox.converter.NullToEmptyStringConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of objectbox-java Show documentation
Show all versions of objectbox-java Show documentation
ObjectBox is a fast NoSQL database for Objects
package io.objectbox.converter;
import javax.annotation.Nullable;
/**
* Used as a converter if a property is annotated with {@link io.objectbox.annotation.DefaultValue @DefaultValue("")}.
*/
public class NullToEmptyStringConverter implements PropertyConverter {
@Override
public String convertToDatabaseValue(String entityProperty) {
return entityProperty;
}
@Override
public String convertToEntityProperty(@Nullable String databaseValue) {
if (databaseValue == null) {
return "";
}
return databaseValue;
}
}