package cn.axzo.msg.center.api.request;

import lombok.Getter;
import lombok.Setter;

/**
 * @author yanglin
 */
@Setter
@Getter
public class VariableAbbreviation {

    public static final int DEFAULT_MAX_LENGTH = 32;

    public static VariableAbbreviation defaultAbbreviate() {
        return abbreviate(DEFAULT_MAX_LENGTH);
    }

    public static VariableAbbreviation abbreviate(int maxLength) {
        if (maxLength <= 0)
            throw new IllegalArgumentException("maxLength must be greater than 0");
        VariableAbbreviation abbreviation = new VariableAbbreviation();
        abbreviation.setAbbreviate(true);
        abbreviation.setMaxLength(maxLength);
        return abbreviation;
    }

    public static VariableAbbreviation noAbbreviation() {
        VariableAbbreviation abbreviation = new VariableAbbreviation();
        abbreviation.setAbbreviate(false);
        return abbreviation;
    }

    /**
     * 是否截断
     */
    private boolean abbreviate;

    /**
     * 最大保留长度
     */
    private int maxLength;

}