spring.turbo.databinding.DirectMessageCodeResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-turbo Show documentation
Show all versions of spring-turbo Show documentation
Another enhancement library of SpringBoot/SpringFramework. Have fun.
The newest version!
package spring.turbo.databinding;
import org.springframework.validation.MessageCodesResolver;
/**
* 简易{@link MessageCodesResolver} 实现。
*
* @author 应卓
* @see #getInstance()
* @since 3.3.1
*/
public final class DirectMessageCodeResolver implements MessageCodesResolver {
/**
* 私有构造方法
*/
private DirectMessageCodeResolver() {
}
/**
* 获取本类型单例
*
* @return 单例实例
*/
public static DirectMessageCodeResolver getInstance() {
return SyncAvoid.INSTANCE;
}
/**
* {@inheritDoc}
*/
@Override
public String[] resolveMessageCodes(String errorCode, String objectName) {
return new String[]{errorCode};
}
/**
* {@inheritDoc}
*/
@Override
public String[] resolveMessageCodes(String errorCode, String objectName, String field, Class> fieldType) {
return new String[]{errorCode};
}
// 延迟加载
private static class SyncAvoid {
private static final DirectMessageCodeResolver INSTANCE = new DirectMessageCodeResolver();
}
}