checkStyleViolationSeverity=error implemented for mdsal-singleton-common-api and...
[mdsal.git] / singleton-service / mdsal-singleton-dom-impl / src / test / java / org / opendaylight / mdsal / singleton / dom / impl / util / TestInstanceIdentifier.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.mdsal.singleton.dom.impl.util;
10
11 import com.google.common.base.Preconditions;
12 import com.google.common.collect.ImmutableList;
13 import java.util.LinkedList;
14 import java.util.List;
15 import org.opendaylight.yangtools.concepts.Path;
16
17 /**
18  * Test helper class. {@link Path} for testing only
19  */
20 public class TestInstanceIdentifier implements Path<TestInstanceIdentifier> {
21
22     static final TestInstanceIdentifier EMPTY_INSTANCE = new TestInstanceIdentifier(ImmutableList.of());
23
24     private final ImmutableList<String> path;
25
26     public TestInstanceIdentifier(final Iterable<? extends TestInstanceIdentifier> path) {
27         Preconditions.checkArgument(path != null);
28         final List<String> tiis = new LinkedList<>();
29         for (final TestInstanceIdentifier t : path) {
30             tiis.add(t.toString());
31         }
32         this.path = ImmutableList.copyOf(tiis);
33     }
34
35     TestInstanceIdentifier(final String path) {
36         this.path = ImmutableList.of(path);
37     }
38
39     @Override
40     public boolean contains(final TestInstanceIdentifier other) {
41         return path.contains(other);
42     }
43
44 }