SorterUtils.java

package com.mycim.utils;

import com.fa.sesa.exception.Assert;
import com.fa.sesa.exception.Errors;
import com.fa.sesa.i18n.I18nUtils;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.valueobject.MessageIdList;
import com.mycim.valueobject.consts.SorterEnum;
import com.mycim.valueobject.ems.Equipment;

public class SorterUtils {

    public static void checkEqptSorterFlagAndError(Equipment equipment) {
        anError(checkEqptSorterFlag(equipment));
    }

    public static String checkEqptSorterFlag(Equipment equipment) {
        if (!StringUtils.equalsIgnoreCase(equipment.getSorterFlag(), "1")) {
            return I18nUtils.getMessage(MessageIdList.EQUIPMENT_NOT_SORTER_EQPT, "{} not the Sorter Eqpt",
                                        equipment.getInstanceId());
        }
        return StringUtils.EMPTY;
    }

    public static String checkSorterType(String sorterType) {
        if (StringUtils.equalsIgnoreCase(sorterType, SorterEnum.Type.OFFLINE.getName())) {
            return I18nUtils.getMessage(MessageIdList.SORTER_TYPE_IS_OFFLINE, "Sorter Model Type is OFFLINE");
        }
        return StringUtils.EMPTY;
    }

    public static Boolean isInLineSorter(String sorterType) {
        return StringUtils.equalsIgnoreCase(sorterType, SorterEnum.Type.INLINE.getName());
    }

    public static void checkSorterTypeAndError(String sorterType) {
        anError(checkSorterType(sorterType));
    }

    public static void anError(String msg) {
        Assert.isTrue(StringUtils.isEmpty(msg), Errors.create().content(msg).build());
    }

}