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

org.redkale.convert.SimpledCoder Maven / Gradle / Ivy

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.redkale.convert;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * 简易类的序列化和反序列化操作类   
* 能序列化为Boolean、Number或者字符串的类视为简易类
* *

* 详情见: https://redkale.org * * @author zhangjx * @param Reader输入的子类 * @param Writer输出的子类 * @param 序列化/反解析的数据类型 */ public abstract class SimpledCoder implements Decodeable, Encodeable { protected Type type; @Override public abstract void convertTo(final W out, final T value); @Override public abstract T convertFrom(final R in); @Override @SuppressWarnings("unchecked") public Class getType() { if (type == null) { Type[] ts = ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments(); type = ts[ts.length - 1]; } return (Class) type; } @Override public String toString() { return this.getClass().getSimpleName(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy