au.org.consumerdatastandards.holder.converter.BankingTransactionServiceConverter Maven / Gradle / Ivy
The newest version!
package au.org.consumerdatastandards.holder.converter;
import au.org.consumerdatastandards.holder.model.banking.BankingTransactionDetailExtendedData;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import java.util.stream.Stream;
@Converter(autoApply = true)
public class BankingTransactionServiceConverter implements AttributeConverter {
@Override
public String convertToDatabaseColumn(BankingTransactionDetailExtendedData.Service attribute) {
if (attribute == null) {
return null;
}
return attribute.toString();
}
@Override
public BankingTransactionDetailExtendedData.Service convertToEntityAttribute(String code) {
if (code == null) {
return null;
}
return Stream.of(BankingTransactionDetailExtendedData.Service.values())
.filter(c -> c.toString().equals(code))
.findFirst()
.orElseThrow(IllegalArgumentException::new);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy