Remove Abstract*Converter

pull/137/head
johnniang 2019-03-11 22:48:36 +08:00
parent 180b111582
commit d7b5bf2e49
2 changed files with 0 additions and 82 deletions

View File

@ -1,40 +0,0 @@
package cc.ryanc.halo.model.dto.base;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import static cc.ryanc.halo.utils.BeanUtils.transformFrom;
import static cc.ryanc.halo.utils.BeanUtils.updateProperties;
/**
* Convenience for input dto.Abstract input dto converter.
*
* @author johnniang
*/
@Deprecated
public abstract class AbstractInputConverter<DOMAIN> implements InputConverter<DOMAIN> {
@SuppressWarnings("unchecked")
private final Class<DOMAIN> domainType = (Class<DOMAIN>) fetchType(0);
@Override
public DOMAIN convertTo() {
return transformFrom(this, domainType);
}
@Override
public void update(DOMAIN domain) {
updateProperties(this, domain);
}
/**
* Get actual generic type.
*
* @param index generic type index
* @return real type will be returned
*/
private Type fetchType(int index) {
return ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[index];
}
}

View File

@ -1,42 +0,0 @@
package cc.ryanc.halo.model.dto.base;
import org.springframework.util.Assert;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import static cc.ryanc.halo.utils.BeanUtils.updateProperties;
/**
* Abstract output dto converter. (it must be extended by DTO)
*
* @author johnniang
*/
@Deprecated
public abstract class AbstractOutputConverter<DTO extends OutputConverter<DTO, DOMAIN>, DOMAIN> implements OutputConverter<DTO, DOMAIN> {
@SuppressWarnings("unchecked")
private final Class<DTO> dtoType = (Class<DTO>) fetchType(0);
public AbstractOutputConverter() {
Assert.isTrue(dtoType.equals(getClass()), "this converter must be extended by DTO type");
}
@Override
@SuppressWarnings("unchecked")
public <T extends DTO> T convertFrom(DOMAIN domain) {
updateProperties(domain, this);
return (T) this;
}
/**
* Get actual generic type.
*
* @param index generic type index
* @return real type will be returned
*/
private Type fetchType(int index) {
return ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[index];
}
}