All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mizhousoft.redis.codec.IntegerCodec Maven / Gradle / Ivy

The newest version!
package com.mizhousoft.redis.codec;

import com.mizhousoft.redis.RedisException;

/**
 * 整形编码器
 *
 * @version
 */
public class IntegerCodec implements Codec
{
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String encode(Integer t) throws RedisException
	{
		if (null == t)
		{
			return null;
		}

		return String.valueOf(t);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Integer decode(String input) throws RedisException
	{
		if (null == input)
		{
			return null;
		}

		try
		{
			return Integer.valueOf(input);
		}
		catch (NumberFormatException e)
		{
			throw new RedisException(input + " is illegal.", e);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy