package com.bytesw.bytebot.etl.converter;

import com.bytesw.bytebot.etl.enums.MessageTypeEnum;

import javax.persistence.AttributeConverter;
import javax.persistence.Converter;

@Converter
public class MessageTypeConverter implements AttributeConverter<MessageTypeEnum, String> {
    @Override
    public String convertToDatabaseColumn(MessageTypeEnum agentTypeEnum) {
        return (agentTypeEnum != null ? agentTypeEnum.getName() : null);
    }

    @Override
    public MessageTypeEnum convertToEntityAttribute(String s) {
        return MessageTypeEnum.fromString(s);
    }
}
