/* * Copyright (c) 2016 Cisco and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.fd.hc2vpp.vppioam.impl.oper; import io.fd.honeycomb.translate.impl.read.GenericInitListReader; import io.fd.honeycomb.translate.read.ReaderFactory; import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; import io.fd.jvpp.ioampot.future.FutureJVppIoampot; import io.fd.jvpp.ioamtrace.future.FutureJVppIoamtrace; import java.util.Arrays; import java.util.List; import javax.annotation.Nonnull; import javax.inject.Inject; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev170327.IoamTraceConfig; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev170327.IoamTraceConfigBuilder; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.ioam.sb.trace.rev170327.ioam.trace.config.TraceConfig; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev170112.PotProfiles; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev170112.PotProfilesBuilder; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev170112.pot.profile.PotProfileList; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev170112.pot.profiles.PotProfileSet; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev170112.pot.profiles.PotProfileSetBuilder; import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.ioam.sb.pot.rev170112.pot.profiles.PotProfileSetKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class VppIoamReaderFactory implements ReaderFactory { @Nonnull FutureJVppIoamtrace jVppIoamTrace; @Nonnull FutureJVppIoampot jVppIoamPot; @Inject VppIoamReaderFactory(FutureJVppIoamtrace jVppIoamTrace, FutureJVppIoampot jVppIoamPot){ this.jVppIoamTrace = jVppIoamTrace; this.jVppIoamPot = jVppIoamPot; } /** * Initialize 1 or more readers and add them to provided registry. * * @param registry Registry */ @Override public void init(@Nonnull ModifiableReaderRegistryBuilder registry) { final PotProfileSetKey STATIC_INSTANCE_KEY = new PotProfileSetKey("static-pot-profile-instance"); final List staticKeys = Arrays.asList(STATIC_INSTANCE_KEY); //IoamTraceConfig (Structural) final InstanceIdentifier ioamTraceConfigId = InstanceIdentifier.create(IoamTraceConfig.class); registry.addStructuralReader(ioamTraceConfigId, IoamTraceConfigBuilder.class); //TraceConfig final InstanceIdentifier traceConfigId = ioamTraceConfigId.child(TraceConfig.class); registry.add(new GenericInitListReader<>(traceConfigId, new TraceProfileReaderCustomizer(jVppIoamTrace))); //PotProfiles (Structural) final InstanceIdentifier potProfilesInstanceIdentifier = InstanceIdentifier.create(PotProfiles.class); registry.addStructuralReader(potProfilesInstanceIdentifier, PotProfilesBuilder.class); //PotProfileSet (Structural) final InstanceIdentifier potProfileSetInstanceIdentifier = potProfilesInstanceIdentifier.child(PotProfileSet.class); registry.addStructuralListReader(potProfileSetInstanceIdentifier, PotProfileSetBuilder.class, staticKeys); //PotProfileList final InstanceIdentifier potProfileListInstanceIdentifier = potProfileSetInstanceIdentifier.child(PotProfileList.class); registry.add(new GenericInitListReader<>(potProfileListInstanceIdentifier, new PotProfileReaderCustomizer(jVppIoamPot))); } }