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

org.reactivecommons.async.starter.props.GenericAsyncPropsDomainProperties Maven / Gradle / Ivy

There is a newer version: 5.2.2
Show newest version
package org.reactivecommons.async.starter.props;

import lombok.Getter;
import lombok.Setter;
import lombok.SneakyThrows;

import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class GenericAsyncPropsDomainProperties, P> extends HashMap {

    public GenericAsyncPropsDomainProperties(Map m) {
        super(m);
    }

    public GenericAsyncPropsDomainProperties() {
    }

    public static ,
            P,
            X extends GenericAsyncPropsDomainProperties> AsyncPropsDomainPropertiesBuilder
    builder(Class returnType) {
        return new AsyncPropsDomainPropertiesBuilder<>(returnType);
    }

    public static class AsyncPropsDomainPropertiesBuilder, P,
            X extends GenericAsyncPropsDomainProperties> {
        private final Map domains = new HashMap<>();
        private final Class returnType;

        public AsyncPropsDomainPropertiesBuilder(Class returnType) {
            this.returnType = returnType;
        }

        public AsyncPropsDomainPropertiesBuilder withDomain(String domain, T props) {
            domains.put(domain, props);
            return this;
        }

        @SneakyThrows
        public X build() {
            return returnType.getDeclaredConstructor(Map.class).newInstance(domains);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy