package cn.superdesk.uniorder.common.numerical;

import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 2020/12/16 上午11:08
 * @UpdateUser: linjinyu
 * @UpdateDate: 2020/12/16 上午11:08
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@NoArgsConstructor
@Slf4j
public class AnIntegerUtils {

	public static Integer getInteger(String input) {

		if (StringUtils.isBlank(input)) {
			return null;
		}

		return Integer.parseInt(input);
	}

	public static Integer getInteger(Object input) {

		String temp = "";

		if (null != input) {
			temp = String.valueOf(input);
		}

		if (StringUtils.isBlank(temp)) {
			return null;
		}

		return Integer.parseInt(temp);
	}

	public static Integer getInteger(Integer input, Integer defaultOut) {

		if (null == input) {
			if (null != defaultOut) {
				input = defaultOut.intValue();
			} else {
				input = 0;
			}
		}

		return input;
	}
}
