* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.neutron.transcriber;
-import com.google.common.collect.ImmutableBiMap;
import java.util.List;
+import javax.inject.Inject;
+import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.neutron.spi.INeutronMeteringLabelRuleCRUD;
import org.opendaylight.neutron.spi.NeutronMeteringLabelRule;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionEgress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.DirectionIngress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.NeutronUtils.DirectionMapper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.metering.rev150712.metering.rules.attributes.MeteringRules;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.metering.rev150712.metering.rules.attributes.metering.rules.MeteringRule;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.metering.rev150712.metering.rules.attributes.metering.rules.MeteringRuleBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.metering.rev150712.metering.rules.attributes.metering.rules.MeteringRuleKey;
+import org.ops4j.pax.cdi.api.OsgiServiceProvider;
+@Singleton
+@OsgiServiceProvider(classes = INeutronMeteringLabelRuleCRUD.class)
public final class NeutronMeteringLabelRuleInterface
extends AbstractNeutronInterface<MeteringRule, MeteringRules, MeteringRuleKey, NeutronMeteringLabelRule>
implements INeutronMeteringLabelRuleCRUD {
- private static final ImmutableBiMap<Class<? extends DirectionBase>,
- String> DIRECTION_MAP = new ImmutableBiMap.Builder<Class<? extends DirectionBase>, String>()
- .put(DirectionEgress.class, "egress").put(DirectionIngress.class, "ingress").build();
- NeutronMeteringLabelRuleInterface(DataBroker db) {
+ @Inject
+ public NeutronMeteringLabelRuleInterface(DataBroker db) {
super(MeteringRuleBuilder.class, db);
}
meteringRuleBuilder.setMeteringLabelId(toUuid(meteringLabelRule.getMeteringLabelRuleLabelID()));
}
if (meteringLabelRule.getMeteringLabelRuleDirection() != null) {
- final ImmutableBiMap<String, Class<? extends DirectionBase>> mapper = DIRECTION_MAP.inverse();
meteringRuleBuilder.setDirection(
- mapper.get(meteringLabelRule.getMeteringLabelRuleDirection()));
+ DirectionMapper.get(meteringLabelRule.getMeteringLabelRuleDirection()));
}
if (meteringLabelRule.getMeteringLabelRuleRemoteIpPrefix() != null) {
final IpPrefix ipPrefix = new IpPrefix(
answer.setMeteringLabelRuleLabelID(rule.getMeteringLabelId().getValue());
}
if (rule.getDirection() != null) {
- answer.setMeteringLabelRuleDirection(DIRECTION_MAP.get(rule.getDirection()));
+ answer.setMeteringLabelRuleDirection(DirectionMapper.getName(rule.getDirection()));
}
if (rule.getRemoteIpPrefix() != null) {
answer.setMeteringLabelRuleRemoteIpPrefix(new String(rule.getRemoteIpPrefix().getValue()));