package com.bytesw.bytebot.model.converters;

import com.bytesw.bytebot.model.enums.AgentTypeEnum;
import org.apache.camel.Converter;

import javax.persistence.AttributeConverter;

@Converter
public class AgentTypeConverter implements AttributeConverter<AgentTypeEnum, String> {
    @Override
    public String convertToDatabaseColumn(AgentTypeEnum agentTypeEnum) {
        if (agentTypeEnum == null) return null;
        return agentTypeEnum.getName();
    }

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