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

com.github.davidmoten.grumpy.wms.LayersBuilder Maven / Gradle / Ivy

package com.github.davidmoten.grumpy.wms;

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

public class LayersBuilder {

    public static LayersBuilder builder() {
        return new LayersBuilder();
    }

    final Map map = new HashMap();

    private LayersBuilder() {
        // private constructor
    }

    public LayersBuilder add(String name, Layer layer) {
        map.put(name, layer);
        return this;
    }

    public Layers build() {
        // make defensive copy
        final Map m = new HashMap(map);
        return new Layers() {

            @Override
            public Layer getLayer(String layerName) {
                Layer layer = m.get(layerName);
                // null return handled by LayerManager with a warning in the log
                return layer;
            }

        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy