All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.objectbox.converter.NullToEmptyStringConverter Maven / Gradle / Ivy

There is a newer version: 4.0.3
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy