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

org.opendaylight.jsonrpc.binding.MultiModelBuilder Maven / Gradle / Ivy

There is a newer version: 1.17.0
Show newest version
/*
 * Copyright (c) 2018 Lumina Networks, Inc. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.jsonrpc.binding;

import com.google.common.base.Preconditions;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.collect.MutableClassToInstanceMap;
import org.opendaylight.yangtools.yang.binding.RpcService;

/**
 * Builder for convenient way to define multiple RpcService implementations.
 *
 * @author Richard Kosegi
 * @since Oct 16, 2018
 */
public final class MultiModelBuilder {
    private final ClassToInstanceMap services = MutableClassToInstanceMap.create();

    private MultiModelBuilder() {
        // no direct instantiation
    }

    public static MultiModelBuilder create() {
        return new MultiModelBuilder();
    }

    public  MultiModelBuilder addService(Class type, T impl) {
        services.put(type, impl);
        return this;
    }

    public ClassToInstanceMap build() {
        Preconditions.checkState(!services.isEmpty(), "No services defined");
        return ImmutableClassToInstanceMap.copyOf(services);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy