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

gu.dtalk.Base64Option Maven / Gradle / Ivy

There is a newer version: 0.8.2
Show newest version
package gu.dtalk;

import com.gitee.l0km.com4j.base.BinaryUtils;
import com.google.common.base.Throwables;

/**
 * base64格式二进制数据选项
 * @author guyadong
 *
 */
public class Base64Option extends BaseBinary {

	public Base64Option() {
	}

	@Override
	public OptionType getType() {
		return OptionType.BASE64;
	}
	@Override
	public Base64Option asValue(String input) {
		try {
			setValue(BinaryUtils.getBytes(input));
			return this;
		} catch (Throwable e) {
			Throwables.throwIfUnchecked(e);
			throw new RuntimeException(e);
		}
	}
	/**
	 * 从input中读取字节流转为byte[]调用{@link #setValue(Object)}
	 * @param  参见 {@link BinaryUtils#getBytes(Object)}
	 */
	public Base64Option asValue(T input) {
		try {
			setValue(BinaryUtils.getBytes(input));
			return this;
		} catch (Throwable e) {
			Throwables.throwIfUnchecked(e);
			throw new RuntimeException(e);
		}
	}
	@Override
	public Base64Option asDefaultValue(String input) {
		try {
			setDefaultValue(BinaryUtils.getBytes(input));
			return this;
		} catch (Throwable e) {
			Throwables.throwIfUnchecked(e);
			throw new RuntimeException(e);
		}
	}
	/**
	 * 从input中读取字节流转为byte[]调用{@link #setDefaultValue(Object)}
	 * @param  参见 {@link BinaryUtils#getBytes(Object)}
	 */
	public Base64Option asDefaultValue(T input) {
		try {
			setDefaultValue(BinaryUtils.getBytes(input));
			return this;
		} catch (Throwable e) {
			Throwables.throwIfUnchecked(e);
			throw new RuntimeException(e);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy