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

org.rx.spring.AppConfigConverters Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package org.rx.spring;

import org.rx.bean.Decimal;
import org.rx.core.Reflects;
import org.rx.net.AuthenticEndpoint;
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.io.File;

//DataSize 和 Duration
public class AppConfigConverters {
    @Component
    @ConfigurationPropertiesBinding
    public static class DecimalConverter implements Converter {
        @Override
        public Decimal convert(Object s) {
            return Decimal.valueOf(s.toString());
        }
    }

    @Component
    @ConfigurationPropertiesBinding
    public static class AuthenticEndpointConverter implements Converter {
        @Override
        public AuthenticEndpoint convert(String s) {
            return new AuthenticEndpoint(s);
        }
    }

    @Component
    @ConfigurationPropertiesBinding
    public static class FileConverter implements Converter {
        @Override
        public File convert(String s) {
            return new File(s);
        }
    }

    @Component
    @ConfigurationPropertiesBinding
    public static class ClassConverter implements Converter> {
        @Override
        public Class convert(String s) {
            return Reflects.loadClass(s, false);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy