package com.ruoyi.web.modules.trading.support;

import java.math.BigDecimal;

/**
 * 市场行情登记常量与枚举校验。
 */
public final class MarketDailyQuoteRules
{
    public static final String DEL_FLAG_NORMAL = "0";

    public static final String DEL_FLAG_DELETED = "2";

    public static final int CATTLE_GENDER_BULL = 1;

    public static final int CATTLE_GENDER_COW = 2;

    public static final int CATTLE_GENDER_MIXED = 3;

    public static final int PRICE_UNIT_PER_HEAD = 1;

    public static final int PRICE_UNIT_PER_JIN = 2;

    public static final int MIN_CHANGE_FACTOR = 1;

    public static final int MAX_CHANGE_FACTOR = 8;

    public static final int MAX_OUTBOUND_ADVICE_LEN = 500;

    public static final BigDecimal PROB_SUM_TARGET = new BigDecimal("100");

    public static final BigDecimal PROB_SUM_TOLERANCE = new BigDecimal("0.01");

    private MarketDailyQuoteRules()
    {
    }

    public static boolean isCattleGenderValid(Integer v)
    {
        return v != null && v >= CATTLE_GENDER_BULL && v <= CATTLE_GENDER_MIXED;
    }

    public static boolean isPriceUnitValid(Integer v)
    {
        return v != null && (v == PRICE_UNIT_PER_HEAD || v == PRICE_UNIT_PER_JIN);
    }

    public static boolean isWeightGradeValid(Integer v)
    {
        return v == null || (v >= 1 && v <= 7);
    }

    public static boolean isGrowthStageValid(Integer v)
    {
        return v == null || (v >= 1 && v <= 3);
    }

    public static boolean isAgeMonthGradeValid(Integer v)
    {
        return v == null || (v >= 1 && v <= 7);
    }

    public static boolean isFatGradeValid(Integer v)
    {
        return v == null || (v >= 1 && v <= 4);
    }

    public static boolean isSupplyStatusValid(Integer v)
    {
        return v != null && v >= 1 && v <= 3;
    }

    public static boolean isChangeFactorCodeValid(int code)
    {
        return code >= MIN_CHANGE_FACTOR && code <= MAX_CHANGE_FACTOR;
    }

    public static int normalizeNullableDim(Integer v)
    {
        return v == null ? 0 : v;
    }
}
