2 * Copyright (c) 2016 Cisco and/or its affiliates.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package io.fd.honeycomb.benchmark.util;
19 import io.fd.honeycomb.translate.read.ReadContext;
20 import io.fd.honeycomb.translate.read.Reader;
21 import java.util.Optional;
22 import javax.annotation.Nonnull;
23 import javax.annotation.concurrent.NotThreadSafe;
24 import org.opendaylight.yangtools.concepts.Builder;
25 import org.opendaylight.yangtools.yang.binding.DataObject;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
29 * Statically preconfigured reader.
32 public final class StaticReader<T extends DataObject, B extends Builder<T>> implements Reader<T, B> {
34 private final InstanceIdentifier<T> id;
35 private final DataProvider data;
36 private long counter = 0;
38 public StaticReader(final InstanceIdentifier<T> id, final DataProvider data) {
45 public InstanceIdentifier<T> getManagedDataObjectType() {
50 public String toString() {
51 return "NoopReader{" +
52 id.getTargetType().getSimpleName() +
53 ", counter=" + counter +
58 public boolean isPresent(@Nonnull final InstanceIdentifier<T> id, @Nonnull final T built,
59 @Nonnull final ReadContext ctx) {
65 public Optional<? extends DataObject> read(@Nonnull final InstanceIdentifier<? extends DataObject> id,
66 @Nonnull final ReadContext ctx) {
68 return Optional.of(data.getData(counter));
72 public void readCurrentAttributes(@Nonnull final InstanceIdentifier<T> id, @Nonnull final B builder,
73 @Nonnull final ReadContext ctx) {
74 throw new UnsupportedOperationException("No read current attrs!");
79 public B getBuilder(final InstanceIdentifier<T> id) {
80 throw new UnsupportedOperationException("No builder!");
84 public void merge(@Nonnull final Builder<? extends DataObject> parentBuilder, @Nonnull final T readValue) {
85 throw new UnsupportedOperationException("No merge!");