2 * Copyright © 2018 Red Hat, Inc. and others.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.genius.infra;
10 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
13 * Strongly-typed representation of a datastore (configuration or operational).
15 * @deprecated Use {@link org.opendaylight.mdsal.binding.util.Datastore} instead.
17 @Deprecated(forRemoval = true)
18 public abstract class Datastore {
20 /** Class representing the configuration datastore. */
21 public static final Class<Configuration> CONFIGURATION = Configuration.class;
23 /** Class representing the operational datastore. */
24 public static final Class<Operational> OPERATIONAL = Operational.class;
26 public static final class Configuration extends Datastore {
30 public static final class Operational extends Datastore {
35 * Returns the logical datastore type corresponding to the given datastore class.
37 * @param datastoreClass The datastore class to convert.
38 * @return The corresponding logical datastore type.
39 * @throws IllegalArgumentException if the provided datastore class isn’t handled.
41 public static LogicalDatastoreType toType(Class<? extends Datastore> datastoreClass) {
42 if (datastoreClass.equals(Configuration.class)) {
43 return LogicalDatastoreType.CONFIGURATION;
44 } else if (Operational.class.equals(datastoreClass)) {
45 return LogicalDatastoreType.OPERATIONAL;
47 throw new IllegalArgumentException("Unknown datastore class " + datastoreClass);
52 * Returns the datastore class corresponding to the given logical datastore type.
53 * @param datastoreType The logical datastore type to convert.
54 * @return The corresponding datastore class.
55 * @throws IllegalArgumentException if the provided logical datastore type isn’t handled.
57 public static Class<? extends Datastore> toClass(LogicalDatastoreType datastoreType) {
58 switch (datastoreType) {
64 throw new IllegalArgumentException("Unknown datastore type " + datastoreType);