
com.redis.om.spring.convert.BytesToBooleanConverter Maven / Gradle / Ivy
package com.redis.om.spring.convert;
import java.nio.charset.StandardCharsets;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;
@ReadingConverter
public class BytesToBooleanConverter implements Converter {
@Override
public Boolean convert(byte[] source) {
String value = toString(source);
return ("1".equals(value) || "true".equalsIgnoreCase(value)) ? Boolean.TRUE : Boolean.FALSE;
}
String toString(byte[] source) {
return new String(source, StandardCharsets.UTF_8);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy