io.geewit.web.convert.converter.EnumValueToLongConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gw-web-converter Show documentation
Show all versions of gw-web-converter Show documentation
A Java Utils Libraray By Geewit
The newest version!
package io.geewit.web.convert.converter;
import io.geewit.core.utils.enums.Value;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.ConditionalConverter;
import org.springframework.core.convert.converter.Converter;
/**
* 自动转换类型
* @param
* @author geewit
*/
public class EnumValueToLongConverter & Value> implements Converter, ConditionalConverter {
@Override
public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
return sourceType.isAssignableTo(TypeDescriptor.valueOf(Value.class)) && sourceType.isAssignableTo(TypeDescriptor.valueOf(Enum.class));
}
@Override
public Long convert(S source) {
return source.value();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy