HONEYCOMB-443: fix benchmark after ODL Neon bump
[honeycomb.git] / infra / it / benchmark / src / main / java / io / fd / honeycomb / benchmark / util / NoopWriter.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package io.fd.honeycomb.benchmark.util;
18
19 import io.fd.honeycomb.translate.write.WriteContext;
20 import io.fd.honeycomb.translate.write.Writer;
21 import org.opendaylight.yangtools.yang.binding.DataObject;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23
24 import javax.annotation.Nonnull;
25 import javax.annotation.Nullable;
26 import javax.annotation.concurrent.NotThreadSafe;
27
28 /**
29  * Noop writer suitable for lists as well.
30  */
31 @NotThreadSafe
32 public final class NoopWriter<T extends DataObject> implements Writer<T> {
33
34     private final InstanceIdentifier<T> id;
35     private long counter = 0;
36
37     public NoopWriter(final InstanceIdentifier<T> id) {
38         this.id = id;
39     }
40
41     @Override
42     public void processModification(@Nonnull final InstanceIdentifier<? extends DataObject> id,
43                        @Nullable final DataObject dataBefore,
44                        @Nullable final DataObject dataAfter,
45                        @Nonnull final WriteContext ctx) {
46         counter++;
47         // NOOP
48     }
49
50     @Nonnull
51     @Override
52     public InstanceIdentifier<T> getManagedDataObjectType() {
53         return id;
54     }
55
56     @Override
57     public String toString() {
58         return "NoopWriter{" +
59                 id.getTargetType().getSimpleName() +
60                 ", counter=" + counter +
61                 '}';
62     }
63
64     @Override
65     public boolean supportsDirectUpdate() {
66         return true;
67     }
68 }