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

com.mntviews.base.module.BridgeBase Maven / Gradle / Ivy

The newest version!
package com.mntviews.base.module;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.mntviews.base.model.DbProperties;
import com.mntviews.base.module.exception.BridgeModuleException;

import java.util.List;
import java.util.Map;

@JsonDeserialize(builder = BridgeBase.Builder.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BridgeBase {

    @JsonProperty("modules")
    private final List modules;

    @JsonProperty("dbs")
    private final Map dbs;

    private BridgeBase(Builder builder) {
        this.modules = builder.modules;
        this.dbs = builder.dbs;
    }

    public List getModules() {
        return modules;
    }

    public BridgeModule findModule(String groupTag, String metaTag) {
        for (BridgeModule bridgeModule:modules) {
            if (bridgeModule.getGroupTag().equals(groupTag) && bridgeModule.getMetaTag().equals(metaTag)) {
                return bridgeModule;
            }
        }
        throw new BridgeModuleException(String.format("Module not found {groupTag=%s,metaTag=%s}",groupTag,metaTag));
    }

    public Map getDbs() {
        return dbs;
    }

    public static Builder custom() {
        return new Builder();
    }

    @JsonPOJOBuilder
    public static class Builder {
        private List modules;
        private Map dbs;

        @JsonProperty("modules")
        public Builder withModules(List modules) {
            this.modules = modules;
            return this;
        }

        @JsonProperty("dbs")
        public Builder withDbs(Map dbs) {
            this.dbs = dbs;
            return this;
        }

        public BridgeBase build() {
            return new BridgeBase(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy