Cleaned up concepts module. 90/1890/2
authorDana Kutenicsova <dkutenic@cisco.com>
Mon, 14 Oct 2013 20:34:07 +0000 (22:34 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Tue, 15 Oct 2013 06:59:54 +0000 (08:59 +0200)
Change-Id: I7345b96a137912babd96994b323c32356325e443
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
29 files changed:
bgp/linkstate/src/test/java/org/opendaylight/protocol/bgp/linkstate/SharedRiskLinkGroupTest.java [deleted file]
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/BGPParserTest.java
concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractAddressFamily.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractIdentifier.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractMetric.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractPrefix.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/AddressFamily.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/IGPMetric.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/Identifier.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/InitialListenerEvents.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/Metric.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/NamedObject.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/NetworkAddress.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/Prefix.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/SharedRiskLinkGroup.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/State.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/Stateful.java [deleted file]
concepts/src/main/java/org/opendaylight/protocol/concepts/TEMetric.java [deleted file]
concepts/src/test/java/org/opendaylight/protocol/concepts/AbstractIdentifierTest.java [deleted file]
concepts/src/test/java/org/opendaylight/protocol/concepts/IGPMetricTest.java [deleted file]
concepts/src/test/java/org/opendaylight/protocol/concepts/TEMetricTest.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/EROIPPrefixSubobject.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/RROIPAddressSubobject.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROIPPrefixSubobject.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/subobject/XROSRLGSubobject.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/Util.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROSRLGSubobjectParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPSubobjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPXROSubobjectParserTest.java

diff --git a/bgp/linkstate/src/test/java/org/opendaylight/protocol/bgp/linkstate/SharedRiskLinkGroupTest.java b/bgp/linkstate/src/test/java/org/opendaylight/protocol/bgp/linkstate/SharedRiskLinkGroupTest.java
deleted file mode 100644 (file)
index b2d1d1d..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.bgp.linkstate;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.opendaylight.protocol.concepts.SharedRiskLinkGroup;
-
-public class SharedRiskLinkGroupTest {
-
-       @Test
-       public void testOverflows() {
-               try {
-                       new SharedRiskLinkGroup(-2);
-                       fail("Constructor successful unexpectedly");
-               } catch(IllegalArgumentException e) {}
-               try {
-                       new SharedRiskLinkGroup(4294967296L);
-                       fail("Constructor successful unexpectedly");
-               } catch(IllegalArgumentException e) {}
-       }
-
-       @Test
-       public void testGetValue() {
-               SharedRiskLinkGroup group = new SharedRiskLinkGroup(252);
-               assertEquals(252, group.getValue());
-       }
-
-       @Test
-       public void testHashCodeEquals() {
-               SharedRiskLinkGroup group1 = new SharedRiskLinkGroup(252);
-               SharedRiskLinkGroup group2 = new SharedRiskLinkGroup(252);
-               SharedRiskLinkGroup group3 = new SharedRiskLinkGroup(987);
-               SharedRiskLinkGroup group4 = group3;
-
-               assertThat(group1.hashCode(), equalTo(group2.hashCode()));
-               assertThat(group1.hashCode(), not(equalTo(group3.hashCode())));
-
-               assertThat(group1, equalTo(group2));
-               assertThat(group1, not(equalTo((group3))));
-               assertThat(group3, equalTo(group4));
-               assertNotNull(group1);
-               assertThat(group1, not(new Object()));
-       }
-
-       @Test
-       public void testCompareTo(){
-               SharedRiskLinkGroup s1 = new SharedRiskLinkGroup(123);
-               SharedRiskLinkGroup s2 = s1;
-               SharedRiskLinkGroup s3 = new SharedRiskLinkGroup(158);
-               assertTrue(s1.compareTo(s2) == 0);
-               assertTrue(s1.compareTo(s3) < 0);
-               assertTrue(s3.compareTo(s1) > 0);
-       }
-
-       @Test
-       public void testEquals(){
-               SharedRiskLinkGroup s1 = new SharedRiskLinkGroup(123);
-               SharedRiskLinkGroup s2 = s1;
-               SharedRiskLinkGroup s3 = new SharedRiskLinkGroup(158);
-               assertFalse(s1.equals(null));
-               assertFalse(s1.equals(new Object()));
-               assertTrue(s1.equals(s2));
-               assertFalse(s1.equals(s3));
-       }
-
-}
index a1a5c50d11ebda7cb2b69e0b2ac1446b225a7531..304b90d72414a4e35a9ff1a55019a8f9d585bd7f 100644 (file)
@@ -26,10 +26,7 @@ import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
 import org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser;
 import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
 import org.opendaylight.protocol.bgp.parser.spi.MessageUtil;
-import org.opendaylight.protocol.concepts.IGPMetric;
-import org.opendaylight.protocol.concepts.Metric;
 import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.util.DefaultingTypesafeContainer;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
@@ -853,8 +850,8 @@ public class BGPParserTest {
                // final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Igp, null);
 
                // network link state
-               final DefaultingTypesafeContainer<Metric<?>> container = new DefaultingTypesafeContainer<Metric<?>>();
-               container.setDefaultEntry(new IGPMetric(1));
+               // final DefaultingTypesafeContainer<Metric<?>> container = new DefaultingTypesafeContainer<Metric<?>>();
+               // container.setDefaultEntry(new IGPMetric(1));
                // final NetworkLinkState linkState = new NetworkLinkState(objState, container, null,
                // LinkProtectionType.UNPROTECTED, null, null, null);
 
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractAddressFamily.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractAddressFamily.java
deleted file mode 100644 (file)
index d72695a..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import java.util.Collections;
-import java.util.Set;
-
-import org.opendaylight.protocol.util.ByteArray;
-import com.google.common.collect.Sets;
-import com.google.common.primitives.UnsignedBytes;
-
-public abstract class AbstractAddressFamily<T extends NetworkAddress<?>> implements AddressFamily<T> {
-       @Override
-       public Set<Prefix<T>> prefixListForBytes(byte[] bytes) {
-               if (bytes.length == 0)
-                       return Collections.emptySet();
-
-               final Set<Prefix<T>> list = Sets.newHashSet();
-               int byteOffset = 0;
-               while (byteOffset < bytes.length) {
-                       final int bitLength = UnsignedBytes.toInt(ByteArray.subByte(bytes, byteOffset, 1)[0]);
-                       byteOffset += 1;
-                       final int byteCount = (bitLength % 8 != 0) ? (bitLength / 8) + 1 : bitLength / 8;
-                       list.add(prefixForBytes(ByteArray.subByte(bytes, byteOffset, byteCount), bitLength));
-                       byteOffset += byteCount;
-               }
-               return list;
-       }
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractIdentifier.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractIdentifier.java
deleted file mode 100644 (file)
index c5fa605..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import java.util.Arrays;
-
-import org.opendaylight.protocol.concepts.Identifier;
-import com.google.common.base.Objects;
-import com.google.common.base.Objects.ToStringHelper;
-
-/**
- * Utility class for implementing identifiers. Subclasses need to provide
- * a byte[] representation of the encapsulated identifier which is unique
- * in its domain. This class then implements the required interfaces.
- *
- * @param <T> template parameter reference to subclass
- */
-public abstract class AbstractIdentifier<T extends AbstractIdentifier<?>> implements Comparable<T>, Identifier {
-       private static final long serialVersionUID = 7024836009610553163L;
-
-       /**
-        * Get raw identifier bytes. Override this method to provide the base
-        * class with a raw representation of your identifier. This is then
-        * used in calculations.
-        *
-        * @return Bytearray representation of the identifier
-        */
-       abstract protected byte[] getBytes();
-
-       abstract protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper);
-
-       @Override
-       public int hashCode() {
-               return Arrays.hashCode(this.getBytes());
-       }
-
-       @Override
-       public boolean equals(final Object o) {
-               if (this == o)
-                       return true;
-               if (o == null)
-                       return false;
-
-               if (this.getClass().equals(o.getClass())
-                               && o instanceof AbstractIdentifier<?>)
-                       return Arrays.equals(this.getBytes(),
-                                       ((AbstractIdentifier<?>) o).getBytes());
-               return false;
-       }
-
-       @Override
-       public int compareTo(final T id) {
-               boolean assignable = this.getClass().isAssignableFrom(id.getClass());
-               if (assignable == false) {
-                       throw new IllegalArgumentException("Object " + id + " is not assignable to " + getClass());
-               }
-
-               final byte[] myb = this.getBytes();
-               final byte[] idb = id.getBytes();
-
-               for (int i = 0; i < idb.length && i < myb.length; ++i) {
-                       if (myb[i] != idb[i])
-                               return myb[i] - idb[i];
-               }
-
-               if (idb.length != myb.length)
-                       return myb.length - idb.length;
-
-               return 0;
-       }
-
-       @Override
-       public final String toString() {
-               return addToStringAttributes(Objects.toStringHelper(this)).toString();
-       }
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractMetric.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractMetric.java
deleted file mode 100644 (file)
index 19f34f6..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-/**
- * Abstract helper class for metrics which are based on integral values,
- * with numberically lower numbers being considered better candidates.
- *
- * @param <T> template reference to subclass
- */
-public abstract class AbstractMetric<T extends AbstractMetric<?>> implements Metric<T> {
-       private static final long serialVersionUID = 4404624006216930524L;
-       private final long value;
-
-       protected AbstractMetric(final long value) {
-               this.value = value;
-       }
-
-       /**
-        * Get the metric value.
-        *
-        * @return Metric value
-        */
-       public long getValue() {
-               return value;
-       }
-
-       @Override
-       public int compareTo(final T other) {
-               if (value < other.getValue())
-                       return -1;
-               if (value > other.getValue())
-                       return 1;
-               return 0;
-       }
-
-       @Override
-       public final int hashCode() {
-               return (int)value;
-       }
-
-       @Override
-       public final boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (obj.getClass() != this.getClass())
-                       return false;
-               return value == ((AbstractMetric<?>)obj).getValue();
-       }
-
-       @Override
-       public String toString() {
-               return String.valueOf(value);
-       }
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractPrefix.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/AbstractPrefix.java
deleted file mode 100644 (file)
index c399661..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-/**
- * Abstract base class for implementing Prefix classes. This class correctly
- * implements all required methods, so to implement a Prefix class, you
- * only need to subclass it and publish an appropriate contructor.
- *
- * @param <T> template parameter reference to subclass
- */
-public abstract class AbstractPrefix<T extends NetworkAddress<T>> implements Comparable<AbstractPrefix<T>>, Prefix<T> {
-
-       private static final long serialVersionUID = -384546010175152481L;
-
-       private final T address;
-       private final int length;
-
-       /**
-        * Create a new prefix object.
-        *
-        * @param address Base network address
-        * @param length Length of significant part of address, in bits
-        */
-       protected AbstractPrefix(final T address, final int length) {
-               this.address = address.applyMask(length);
-               this.length = length;
-       }
-
-       @Override
-       public T getAddress() {
-               return this.address;
-       }
-
-       @Override
-       public int getLength() {
-               return this.length;
-       }
-
-       @Override
-       public int compareTo(final AbstractPrefix<T> p) {
-               final int i = this.address.compareTo(p.getAddress());
-               if (i != 0)
-                       return i;
-               if (this.length < p.getLength())
-                       return -1;
-               if (this.length > p.getLength())
-                       return 1;
-               return 0;
-       }
-
-       @Override
-       public boolean contains(final NetworkAddress<?> address) {
-               /*
-                * Fastest way of checking this is to apply this prefixe's
-                * mask and check for equality.
-                */
-               final NetworkAddress<?> masked = address.applyMask(this.length);
-               return this.address.equals(masked);
-       }
-
-       /**
-        * {@inheritDoc}
-        *
-        * Returned string will be in the CIDR format.
-        */
-       @Override
-       public String toString() {
-               final StringBuilder sb = new StringBuilder(this.address.toString());
-               sb.append('/');
-               sb.append(this.length);
-               return sb.toString();
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (this.getClass() != obj.getClass())
-                       return false;
-               final AbstractPrefix<?> other = (AbstractPrefix<?>) obj;
-               if (this.address == null) {
-                       if (other.address != null)
-                               return false;
-               } else if (!this.address.equals(other.address))
-                       return false;
-               if (this.length != other.length)
-                       return false;
-               return true;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + ((this.address == null) ? 0 : this.address.hashCode());
-               result = prime * result + this.length;
-               return result;
-       }
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/AddressFamily.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/AddressFamily.java
deleted file mode 100644 (file)
index 973b46a..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import java.util.Set;
-
-/**
- * Interface marking an Address Family concept. An address family defines
- * a NetworkAddress type, corresponding Prefix type as well as their textual
- * representations.
- * 
- * @param <T> Network Address type
- */
-public interface AddressFamily<T extends NetworkAddress<?>> {
-       /**
-        * Attempt to parse an address from a string. 
-        * 
-        * @param string String representation of the address
-        * @return A network address instance
-        * @throws IllegalArgumentException if string is null or does not conform
-        *         to address encoding rules.
-        */
-       public T addressForString(String string);
-
-       /**
-        * Attempt to parse a parse from a string. 
-        * 
-        * @param string String representation of the prefix
-        * @return A prefix instance
-        * @throws IllegalArgumentException if string is null or does not conform
-        *         to prefix encoding rules.
-        * @throws NumberFormatException if the prefix length is not a parseable
-        *         number.
-        */
-       public Prefix<T> prefixForString(String string);
-
-       /**
-        * Create a network address from a its byte representation.
-        *
-        * @param bytes address as a byte array
-        * @return {@link NetworkAddress}
-        * @throws IllegalArgumentException if the provided byte array
-        *         does not conform to address formatting rules
-        */
-       public T addressForBytes(byte[] bytes);
-
-       /**
-        * Parse a byte array into a Prefix of specified length
-        *
-        * @param bytes array to be parsed to a Prefix
-        * @param bitLength
-        *            length of the prefix in bits, to be given as parameter when
-        *            initializing a Prefix
-        * @return new Prefix
-        */
-       public Prefix<T> prefixForBytes(byte[] bytes, int bitLength);
-
-       /**
-        * Parse given byte array to a list of prefixes.
-        *
-        * @param bytes byte array to be parsed.
-        * @return list of prefixes, if bytes is empty, returns empty list.
-        */
-       public Set<? extends Prefix<T>> prefixListForBytes(byte[] bytes);
-
-       /**
-        * Returns the number of bytes required for successful address
-        * reconstruction via {@link addressForBytes}
-        * 
-        * @return number of bytes required
-        */
-       public int requiredBytes();
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/IGPMetric.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/IGPMetric.java
deleted file mode 100644 (file)
index 48eedb7..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-/**
- * Interior Gateway Protocol metric class.
- */
-public final class IGPMetric extends AbstractMetric<IGPMetric> {
-       private static final long serialVersionUID = -401875021705133799L;
-
-       /**
-        * Construct a new IGP metric object.
-        *
-        * @param value Metric value
-        * @throws IllegalArgumentException ex when value is outside of allowed
-        *         range (0-16777215)
-        */
-       public IGPMetric(final long value) {
-               super(value);
-               if (value < 0 || value > 16777215)
-                       throw new IllegalArgumentException("Invalid IGP metric value");
-       }
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/Identifier.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/Identifier.java
deleted file mode 100644 (file)
index bbaffd7..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import java.io.Serializable;
-
-/**
- * General identifier interface. It is primarily a marker for all things that
- * identify concepts -- such as names, addresses, classes, etc. We do not
- * require too much, just that the identifiers are serializable (and this
- * transferable).
- */
-public interface Identifier extends Serializable {
-
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/InitialListenerEvents.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/InitialListenerEvents.java
deleted file mode 100644 (file)
index 1564550..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import java.util.EventListener;
-import java.util.List;
-
-public final class InitialListenerEvents<L extends EventListener, E> {
-       private final ListenerRegistration<L> registration;
-       private final List<E> events;
-
-       public InitialListenerEvents(final ListenerRegistration<L> registration, final List<E> events) {
-               super();
-               if (registration == null)
-                       throw new NullPointerException("Registration is mandatory!");
-               this.registration = registration;
-               if (events == null)
-                       throw new NullPointerException("Events are mandatory!");
-               this.events = events;
-       }
-
-       /**
-        * @return the registration
-        */
-       public ListenerRegistration<L> getRegistration() {
-               return this.registration;
-       }
-
-       /**
-        * @return the events
-        */
-       public List<E> getEvents() {
-               return this.events;
-       }
-}
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/Metric.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/Metric.java
deleted file mode 100644 (file)
index 2156afa..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import java.io.Serializable;
-
-/**
- * Interface defining the concept of a metric. Metrics are something which
- * defines preference of an object when used in a certain context. In that
- * sense we define total ordering of metrics in the same class.
- *
- * @param <T> subtype of Metric
- */
-public interface Metric<T extends Metric<?>> extends Comparable<T>, Serializable {
-       /**
-        * {@inheritDoc}
-        *
-        * Metrics which compare as 'lower' using this method are to be
-        * considered better candidates than the other metric.
-        */
-       @Override
-       public int compareTo(T o);
-
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/NamedObject.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/NamedObject.java
deleted file mode 100644 (file)
index c403e19..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-/**
- * General interface for identifyiable objects. Useful when you have an object
- * which has a sense of identity -- by having a "name".
- *
- * @param <T> template reference to the object name's Identifier class
- */
-public interface NamedObject<T extends Identifier> {
-       /**
-        * Get the object's Identifier (or "name"). A name uniquely identifies
-        * an object among its peers. Two named objects can have the same
-        * identifier, but need not necessarily be equal.
-        *
-        * @return The object's identifier
-        */
-       public T getName();
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/NetworkAddress.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/NetworkAddress.java
deleted file mode 100644 (file)
index ec534bb..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import org.opendaylight.protocol.concepts.Identifier;
-
-/**
- * Generic identifier of a network entity. A network entity is typically a
- * host. Hosts may be contained within a network -- which is represented by
- * a @sa Prefix. To support operation within the context of a prefix,
- * NetworkAddresses have to support a concept of 'masking', where all bits
- * beyond first <n> bit are set to 0 and any bytes are trimmed.
- *
- * @param <T> subtype of Network Address
- */
-public interface NetworkAddress<T extends NetworkAddress<?>> extends Comparable<T>, Identifier {
-       /**
-        * Returns the raw address of this object. The result is in network
-        * byte order: the highest order byte of the address is in
-        * getAddress()[0].
-        * 
-        * @return the raw address of this object, guaranteed to be non-null
-        */
-       public byte[] getAddress();
-
-       /**
-        * Apply a mask of first #bits, setting the rest to zero.
-        *
-        * @param bits Number of bits to keep in place. Has to be
-        *                 non-negative.
-        * @return A new NetworkAddress instance.
-        */
-       public T applyMask(int bits);
-
-       /**
-        * Convert the address into a prefix of specified length.
-        *
-        * @param length Prefix length
-        * @return A prefix representation of this address.
-        */
-       public Prefix<T> asPrefix(int length);
-
-       /**
-        * Convert the address into a host prefix, e.g. a prefix with length
-        * equal to the address bitsize.
-        *
-        * @return A prefix representation of this address.
-        */
-       public Prefix<T> asHostPrefix();
-
-       /**
-        * Returns the address family class.
-        * 
-        * @return address family class
-        */
-       public AddressFamily<T> getAddressFamily();
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/Prefix.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/Prefix.java
deleted file mode 100644 (file)
index 87d8524..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import org.opendaylight.protocol.concepts.Identifier;
-
-/**
- * A network prefix object. Prefix is a networking concept grouping together
- * a set of addresses into a 'subnet', such that their attributes can be easily
- * expressed. A prefix is formed by a base NetworkAddress and number of leading
- * bits which are considered significant. An address is considered to be a part
- * of a prefix if it differes only in insignificant (right-most) bits.
- *
- * @param <T> template reference to a Network Address class
- */
-public interface Prefix<T extends NetworkAddress<?>> extends Identifier {
-       /**
-        * Get the base address of the prefix.
-        *
-        * @return Base network address
-        */
-       public T getAddress();
-
-       /**
-        * The the length of significant part of the base address.
-        *
-        * @return Prefix length
-        */
-       public int getLength();
-
-       /**
-        * Check if a Prefix contains a particular network address.
-        *
-        * @param address Network address to check for membership
-        * @return true if address belongs to this subnet, false otherwise
-        */
-       public boolean contains(NetworkAddress<?> address);
-
-       /**
-        * Returns the address family class.
-        * 
-        * @return address family class
-        */
-       public AddressFamily<T> getAddressFamily();
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/SharedRiskLinkGroup.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/SharedRiskLinkGroup.java
deleted file mode 100644 (file)
index 36aa72f..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-
-/**
- * Class representing a Shared Risk Link Group identifier. A link may be
- * part of multiple such groups. Membership in such a group indicates that
- * members share a common risk (such as single wire, etc.).
- */
-public class SharedRiskLinkGroup implements Comparable<SharedRiskLinkGroup>, Identifier {
-       private static final long serialVersionUID = -760766663668819360L;
-       private final long value;
-
-       /**
-        * Create a new group with a particular value. Valid values are in
-        * the range of 0-4294967295. Two groups with the same value are
-        * considered equal.
-        * @param value SRLG value
-        */
-       public SharedRiskLinkGroup(final long value) {
-               if (value < 0 || value > 4294967295L)
-                       throw new IllegalArgumentException("Invalid SRLG value");
-               this.value = value;
-       }
-
-       /**
-        * Returns value attribute of {@link SharedRiskLinkGroup}.
-        * @return value of {@link SharedRiskLinkGroup}
-        */
-       public long getValue() {
-               return value;
-       }
-
-       @Override
-       public int compareTo(final SharedRiskLinkGroup other) {
-               if (value < other.value)
-                       return -1;
-               if (value > other.value)
-                       return 1;
-               return 0;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + (int) (value ^ (value >>> 32));
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj)
-                       return true;
-               if (obj == null)
-                       return false;
-               if (!(obj instanceof SharedRiskLinkGroup))
-                       return false;
-               final SharedRiskLinkGroup other = (SharedRiskLinkGroup) obj;
-               if (value != other.value)
-                       return false;
-               return true;
-       }
-}
-
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/State.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/State.java
deleted file mode 100644 (file)
index 404e01d..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import java.io.Serializable;
-
-/**
- * Interface identifying a piece of state information. Implementations of this interface are required to be immutable.
- * It is also recommended for the projects to be eligible (and carry) the @Immutable JSR-305 annotation.
- */
-public interface State extends Immutable, Serializable {
-       /**
-        * Report a string representation of the state. The interface contract of this method, unlike its normal Object
-        * ancestor, its return value must be consistent with the equals() method, such that the following always holds:
-        * 
-        * o1.toString().equals(o2.toString()) == o1.equals(o2)
-        * 
-        * @return String representation of the state information
-        */
-       @Override
-       public String toString();
-}
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/Stateful.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/Stateful.java
deleted file mode 100644 (file)
index 0e0bdb3..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-/**
- * Interface marking object which hold some state, which can be captured and saved. Capturing this state is useful for
- * various entities which need to see a consistent, point-in-time view of the state.
- * 
- * @param <T> Type reference of the returned state object
- */
-public interface Stateful<T extends State> {
-       /**
-        * Return a reference to the current state of the object. The returned object must remain immutable throughout its
-        * lifetime. Furthermore using equals() on two state objects returned from this method must return true if and only
-        * if the internal state of this object the the two points was equivalent.
-        * 
-        * @return Reference to a point-in-time consistent state of the object.
-        */
-       public T currentState();
-}
diff --git a/concepts/src/main/java/org/opendaylight/protocol/concepts/TEMetric.java b/concepts/src/main/java/org/opendaylight/protocol/concepts/TEMetric.java
deleted file mode 100644 (file)
index 4c08dd4..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import javax.annotation.concurrent.Immutable;
-
-/**
- * Traffic Engineering metric class.
- */
-@Immutable
-public final class TEMetric extends AbstractMetric<TEMetric> {
-       private static final long serialVersionUID = -6843828299489991771L;
-
-       /**
-        * Construct a new TE metric object.
-        *
-        * @param value Metric value
-        * @throws IllegalArgumentException ex when value is outside of allowed
-        *         range (0-4294967295)
-        */
-       public TEMetric(final long value) {
-               super(value);
-               if (value < 0 || value > 4294967295L)
-                       throw new IllegalArgumentException("Invalid TE metric value");
-       }
-}
-
diff --git a/concepts/src/test/java/org/opendaylight/protocol/concepts/AbstractIdentifierTest.java b/concepts/src/test/java/org/opendaylight/protocol/concepts/AbstractIdentifierTest.java
deleted file mode 100644 (file)
index 068567e..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-import org.opendaylight.protocol.util.ByteArray;
-import com.google.common.base.Objects.ToStringHelper;
-
-public class AbstractIdentifierTest {
-
-       private class AbstractIdentifierT extends AbstractIdentifier<AbstractIdentifierT> {
-
-               private static final long serialVersionUID = 3803643153695225193L;
-
-               public byte[] bytes;
-
-               public AbstractIdentifierT(final byte[] bytes) {
-                       this.bytes = bytes;
-               }
-
-               @Override
-               protected byte[] getBytes() {
-                       return this.bytes;
-               }
-
-               @Override
-               protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-                       return toStringHelper.add("bytes", ByteArray.toHexString(bytes, "."));
-               }
-       }
-
-       @Test
-       public void testToString() {
-               final AbstractIdentifier<AbstractIdentifierT> ai = new AbstractIdentifierT(new byte[] {(byte) 172, (byte) 168, 31, 8});
-
-               assertEquals("AbstractIdentifierT{bytes=ac.a8.1f.08}", ai.toString());
-       }
-
-
-       @Test
-       public void testCompareTo() {
-               final AbstractIdentifier<AbstractIdentifierT> a1 = new AbstractIdentifierT(new byte[] {(byte) 172, (byte) 168, 31, 8});
-               final AbstractIdentifier<AbstractIdentifierT> a2 = new AbstractIdentifierT(new byte[] {(byte) 172, (byte) 167, 31, 8});
-               final AbstractIdentifier<AbstractIdentifierT> a4 = new AbstractIdentifierT(new byte[] {(byte) 172, (byte) 167});
-
-               assertEquals(0, a1.compareTo((AbstractIdentifierT) a1));
-               assertEquals(-1, a2.compareTo((AbstractIdentifierT) a1));
-               assertEquals(1, a1.compareTo((AbstractIdentifierT) a2));
-
-               final AbstractIdentifier<AbstractIdentifier<?>> a3 = new AbstractIdentifier<AbstractIdentifier<?>>() {
-
-                       private static final long serialVersionUID = 1L;
-
-                       @Override
-                       protected byte[] getBytes() {
-                               return null;
-                       }
-
-                       @Override
-                       protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-                               return toStringHelper;
-                       }
-               };
-
-               try {
-                       a3.compareTo(a1);
-                       fail("Exception should have occured.");
-               } catch (final IllegalArgumentException e) {
-                       assertEquals("Object " + a1 + " is not assignable to " + a3.getClass() , e.getMessage());
-               }
-
-               assertEquals(2, a2.compareTo((AbstractIdentifierT) a4));
-       }
-
-       @Test
-       public void testHashCodeEquals() {
-               final AbstractIdentifier<AbstractIdentifierT> a1 = new AbstractIdentifierT(new byte[] {(byte) 172, (byte) 168, 31, 8});
-               final AbstractIdentifier<AbstractIdentifierT> a2 = new AbstractIdentifierT(new byte[] {(byte) 172, (byte) 167, 31, 8});
-
-               assertNotSame(a1.hashCode(), a2.hashCode());
-               assertFalse(a1.equals(a2));
-               assertEquals(a1, a1);
-       }
-}
diff --git a/concepts/src/test/java/org/opendaylight/protocol/concepts/IGPMetricTest.java b/concepts/src/test/java/org/opendaylight/protocol/concepts/IGPMetricTest.java
deleted file mode 100644 (file)
index 3f71805..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-
-public class IGPMetricTest {
-
-       @Test
-       public void testOverflows() {
-               try {
-                       new IGPMetric(-2);
-                       fail("Constructor successful unexpectedly");
-               } catch(IllegalArgumentException e) {}
-               try {
-                       new IGPMetric(16777216);
-                       fail("Constructor successful unexpectedly");
-               } catch(IllegalArgumentException e) {}
-       }
-
-       @Test
-       public void testGetValue() {
-               IGPMetric metric = new IGPMetric(951357);
-               assertEquals(951357, metric.getValue());
-       }
-
-       @Test
-       public void testEqualsObject() {
-               IGPMetric metric1 = new IGPMetric(159357);
-               IGPMetric metric2 = new IGPMetric(159357);
-               IGPMetric metric3 = new IGPMetric(258456);
-               IGPMetric metric4 = metric3;
-
-               assertEquals(metric1, metric2);
-               assertEquals(metric1.hashCode(), metric2.hashCode());
-               assertEquals(metric3, metric4);
-               assertNotNull(metric1);
-               assertThat(metric1, not(new Object()));
-               assertThat(metric1, not(metric3));
-               assertThat(metric1.hashCode(), not(metric3.hashCode()));
-       }
-
-}
diff --git a/concepts/src/test/java/org/opendaylight/protocol/concepts/TEMetricTest.java b/concepts/src/test/java/org/opendaylight/protocol/concepts/TEMetricTest.java
deleted file mode 100644 (file)
index db7f120..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.protocol.concepts;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-import org.junit.Test;
-
-public class TEMetricTest {
-
-       @Test
-       public void testOverflows() {
-               try {
-                       new TEMetric(-2);
-                       fail("Constructor successful unexpectedly");
-               } catch(IllegalArgumentException e) {}
-               try {
-                       new TEMetric(4294967296L);
-                       fail("Constructor successful unexpectedly");
-               } catch(IllegalArgumentException e) {}
-       }
-
-       @Test
-       public void testGetValue() {
-               TEMetric metric = new TEMetric(951357);
-               assertEquals(951357, metric.getValue());
-       }
-
-       @Test
-       public void testEqualsObject() {
-               TEMetric metric1 = new TEMetric(159357);
-               TEMetric metric2 = new TEMetric(159357);
-               TEMetric metric3 = new TEMetric(258456);
-               TEMetric metric4 = metric3;
-
-               assertEquals(metric1, metric2);
-               assertEquals(metric1.hashCode(), metric2.hashCode());
-               assertEquals(metric3, metric4);
-               assertNotNull(metric1);
-               assertThat(metric1, not(equalTo(new Object())));
-               assertThat(metric1, not(equalTo(metric3)));
-               assertThat(metric1.hashCode(), not(equalTo(metric3.hashCode())));
-       }
-}
-
index ef8a3247644a2b19be41c0c240a1ee02934da902..6f4f9c8e9b95777cce2c539d4b44e0d873c4276d 100644 (file)
@@ -8,43 +8,39 @@
 
 package org.opendaylight.protocol.pcep.subobject;
 
-import org.opendaylight.protocol.concepts.Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+
 import com.google.common.base.Objects.ToStringHelper;
 
 /**
  * Parametrized structure of IP Prefix Subobject.
- *
- * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.2">Section
- *      4.3.3.2.: Subobject 1: IPv4 prefix</a> and <a
- *      href="http://tools.ietf.org/html/rfc3209#section-4.3.3.3">Section
- *      4.3.3.2.: Subobject 2: IPv6 prefix</a>
- *
- * @param <T>
- *            subtype of Prefix
+ * 
+ * @see <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.2">Section 4.3.3.2.: Subobject 1: IPv4 prefix</a> and
+ *      <a href="http://tools.ietf.org/html/rfc3209#section-4.3.3.3">Section 4.3.3.2.: Subobject 2: IPv6 prefix</a>
+ * 
+ * @param <T> subtype of Prefix
  */
-public class EROIPPrefixSubobject<T extends Prefix<?>> extends ExplicitRouteSubobject {
+public class EROIPPrefixSubobject extends ExplicitRouteSubobject {
 
-       private final T prefix;
+       private final IpPrefix prefix;
 
        /**
         * Constructs IPPrefix Subobject.
-        *
-        * @param prefix
-        *            T
-        * @param loose
-        *            boolean
+        * 
+        * @param prefix T
+        * @param loose boolean
         */
-       public EROIPPrefixSubobject(T prefix, boolean loose) {
+       public EROIPPrefixSubobject(final IpPrefix prefix, final boolean loose) {
                super(loose);
                this.prefix = prefix;
        }
 
        /**
         * Gets specific {@link Prefix}.
-        *
+        * 
         * @return prefix T
         */
-       public T getPrefix() {
+       public IpPrefix getPrefix() {
                return this.prefix;
        }
 
@@ -57,14 +53,14 @@ public class EROIPPrefixSubobject<T extends Prefix<?>> extends ExplicitRouteSubo
        }
 
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (this.getClass() != obj.getClass())
                        return false;
-               final EROIPPrefixSubobject<?> other = (EROIPPrefixSubobject<?>) obj;
+               final EROIPPrefixSubobject other = (EROIPPrefixSubobject) obj;
                if (this.prefix == null) {
                        if (other.prefix != null)
                                return false;
@@ -73,8 +69,8 @@ public class EROIPPrefixSubobject<T extends Prefix<?>> extends ExplicitRouteSubo
                return true;
        }
 
-    @Override
-       protected ToStringHelper addToStringAttributes(ToStringHelper toStringHelper) {
+       @Override
+       protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
                toStringHelper.add("prefix", this.prefix);
                return super.addToStringAttributes(toStringHelper);
        }
index cc05272b17d69c7dca61d050d3444ec651035a34..90a75b7884e86c0eb87916ff3af46c1b063a9e1f 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.protocol.pcep.subobject;
 
-import org.opendaylight.protocol.concepts.Prefix;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
 
 /**
index f04c6c9e7f6f4cd9437cd90a32b16fbbd4e6a17d..04946b036cd2eb26d07d78465650ad54a277ff24 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.protocol.pcep.subobject;
 
-import org.opendaylight.protocol.concepts.Prefix;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
 
 /**
index 803b699b6d648a4a80c917a110f42aa9c608b519..1a0e90e642fc7576217426950212ae06ab574f7a 100644 (file)
@@ -7,46 +7,41 @@
  */
 package org.opendaylight.protocol.pcep.subobject;
 
-import org.opendaylight.protocol.concepts.SharedRiskLinkGroup;
-
 /**
  * Structure of Shared Risk Link Group Subobject. Defined in RFC5521.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route
- *      Object definition</a>
+ * 
+ * @see <a href="http://tools.ietf.org/html/rfc5521#section-2.1.1">Exclude Route Object definition</a>
  */
 public class XROSRLGSubobject extends ExcludeRouteSubobject {
 
        private final XROSubobjectAttribute attribute;
 
-       private final SharedRiskLinkGroup srlgId;
+       // private final SharedRiskLinkGroup srlgId;
 
        /**
         * Constructs new Shared Risk Link Group Subobject.
-        *
-        * @param srlgId
-        *            SharedRiskLinkGroup
-        * @param mandatory
-        *            boolean
+        * 
+        * @param srlgId SharedRiskLinkGroup
+        * @param mandatory boolean
         */
-       public XROSRLGSubobject(SharedRiskLinkGroup srlgId, boolean mandatory) {
+       public XROSRLGSubobject(final boolean mandatory) {
                super(mandatory);
                this.attribute = XROSubobjectAttribute.SRLG;
-               this.srlgId = srlgId;
+               // this.srlgId = srlgId;
        }
 
        /**
         * Gets the Shared Risk Link Group.
-        *
+        * 
         * @return SharedRiskLinkGroup
         */
-       public SharedRiskLinkGroup getSrlgId() {
-               return this.srlgId;
-       }
+       // public SharedRiskLinkGroup getSrlgId() {
+       // return this.srlgId;
+       // }
 
        /**
         * Gets the attribute of the subobject
-        *
+        * 
         * @return the attribute
         */
        public XROSubobjectAttribute getAttribute() {
@@ -58,8 +53,6 @@ public class XROSRLGSubobject extends ExcludeRouteSubobject {
                final StringBuilder builder = new StringBuilder();
                builder.append("XROSRLGSubobject [attribute=");
                builder.append(this.attribute);
-               builder.append(", srlgId=");
-               builder.append(this.srlgId.getValue());
                builder.append(", mandatory=");
                builder.append(this.mandatory);
                builder.append("]");
@@ -71,12 +64,11 @@ public class XROSRLGSubobject extends ExcludeRouteSubobject {
                final int prime = 31;
                int result = super.hashCode();
                result = prime * result + ((this.attribute == null) ? 0 : this.attribute.hashCode());
-               result = prime * result + ((this.srlgId == null) ? 0 : this.srlgId.hashCode());
                return result;
        }
 
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (!super.equals(obj))
@@ -86,11 +78,6 @@ public class XROSRLGSubobject extends ExcludeRouteSubobject {
                final XROSRLGSubobject other = (XROSRLGSubobject) obj;
                if (this.attribute != other.attribute)
                        return false;
-               if (this.srlgId == null) {
-                       if (other.srlgId != null)
-                               return false;
-               } else if (!this.srlgId.equals(other.srlgId))
-                       return false;
                return true;
        }
 
index ff5180240b93d9760e7b7b7dec4a4cb49cfdcec1..25da97caff3a443ccfeb8afd533f6152579f1abe 100644 (file)
@@ -7,20 +7,22 @@
  */
 package org.opendaylight.protocol.pcep.impl;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 
-import org.opendaylight.protocol.concepts.AddressFamily;
-import org.opendaylight.protocol.concepts.NetworkAddress;
+import org.opendaylight.protocol.concepts.Ipv4Util;
+import org.opendaylight.protocol.concepts.Ipv6Util;
 import org.opendaylight.protocol.pcep.PCEPErrorMapping;
 import org.opendaylight.protocol.pcep.PCEPErrorMapping.PCEPErrorIdentifier;
 import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.address.family.Ipv4;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors;
@@ -28,6 +30,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.SessionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.session.Open;
 
+import com.google.common.collect.Lists;
+
 /**
  * Utilities used in pcep-impl
  */
@@ -55,22 +59,26 @@ public final class Util {
                }
        }
 
-       public static <T extends NetworkAddress<T>> List<T> parseAddresses(final byte[] bytes, int offset, final AddressFamily<T> family,
-                       final int addrLen) {
-               final List<T> addresses = new ArrayList<T>();
+       public static List<IpAddress> parseAddresses(final byte[] bytes, int offset, final AddressFamily family, final int addrLen) {
+               final List<IpAddress> addresses = Lists.newArrayList();
 
                while (bytes.length > offset) {
-                       addresses.add(family.addressForBytes(ByteArray.subByte(bytes, offset, addrLen)));
+                       if (family instanceof Ipv4)
+                               addresses.add(new IpAddress(Ipv4Util.addressForBytes(ByteArray.subByte(bytes, offset, addrLen))));
+                       else
+                               addresses.add(new IpAddress(Ipv6Util.addressForBytes(ByteArray.subByte(bytes, offset, addrLen))));
                        offset += addrLen;
                }
 
                return addresses;
        }
 
-       public static <T extends NetworkAddress<T>> void putAddresses(final byte[] destBytes, int offset, final List<T> addresses,
-                       final int addrLen) {
-               for (final T address : addresses) {
-                       System.arraycopy(address.getAddress(), 0, destBytes, offset, addrLen);
+       public static void putAddresses(final byte[] destBytes, int offset, final List<IpAddress> addresses, final int addrLen) {
+               for (final IpAddress address : addresses) {
+                       if (address.getIpv4Address() != null)
+                               System.arraycopy(address.getIpv4Address().getValue().getBytes(), 0, destBytes, offset, addrLen);
+                       else
+                               System.arraycopy(address.getIpv6Address().getValue().getBytes(), 0, destBytes, offset, addrLen);
                        offset += addrLen;
                }
        }
index e1a041c3731d50a399c176daff742355e6e192e0..1688ce3093cf47cf747425d6dbd8a2ad4468551d 100644 (file)
@@ -7,45 +7,48 @@
  */
 package org.opendaylight.protocol.pcep.impl.subobject;
 
-import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.protocol.concepts.SharedRiskLinkGroup;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
 import org.opendaylight.protocol.pcep.subobject.XROSRLGSubobject;
-import com.google.common.primitives.UnsignedInts;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.subobject. XROSRLGSubobject
- * XROSRLGSubobject}
+ * Parser for {@link org.opendaylight.protocol.pcep.subobject. XROSRLGSubobject XROSRLGSubobject}
  */
 public class XROSRLGSubobjectParser {
        public static final int SRLG_ID_NUMBER_LENGTH = 4;
        public static final int ATTRIBUTE_LENGTH = 1;
 
        public static final int SRLG_ID_NUMBER_OFFSET = 0;
-       public static final int ATTRIBUTE_OFFSET = SRLG_ID_NUMBER_OFFSET + SRLG_ID_NUMBER_LENGTH + 1; // added reserved field of size 1
+       public static final int ATTRIBUTE_OFFSET = SRLG_ID_NUMBER_OFFSET + SRLG_ID_NUMBER_LENGTH + 1; // added reserved
+                                                                                                                                                                                                       // field of size 1
 
        public static final int CONTENT_LENGTH = ATTRIBUTE_OFFSET + ATTRIBUTE_LENGTH;
 
-       public static XROSRLGSubobject parse(byte[] soContentsBytes, boolean mandatory) throws PCEPDeserializerException {
+       public static XROSRLGSubobject parse(final byte[] soContentsBytes, final boolean mandatory) throws PCEPDeserializerException {
                if (soContentsBytes == null || soContentsBytes.length == 0)
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
                if (soContentsBytes.length != CONTENT_LENGTH)
-                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: " + CONTENT_LENGTH + ".");
-
-               return new XROSRLGSubobject(new SharedRiskLinkGroup(UnsignedInts.toLong(ByteArray.bytesToInt(ByteArray.subByte(soContentsBytes, SRLG_ID_NUMBER_OFFSET,
-                               SRLG_ID_NUMBER_LENGTH)))), mandatory);
+                       throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + soContentsBytes.length + "; Expected: "
+                                       + CONTENT_LENGTH + ".");
+
+               // return new XROSRLGSubobject(new
+               // SharedRiskLinkGroup(UnsignedInts.toLong(ByteArray.bytesToInt(ByteArray.subByte(soContentsBytes,
+               // SRLG_ID_NUMBER_OFFSET,
+               // SRLG_ID_NUMBER_LENGTH)))), mandatory);
+               return null;
        }
 
-       public static byte[] put(ExcludeRouteSubobject objToSerialize) {
+       public static byte[] put(final ExcludeRouteSubobject objToSerialize) {
                if (!(objToSerialize instanceof XROSRLGSubobject))
-                       throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + objToSerialize.getClass() + ". Needed XROSRLGSubobject.");
+                       throw new IllegalArgumentException("Unknown PCEPXROSubobject instance. Passed " + objToSerialize.getClass()
+                                       + ". Needed XROSRLGSubobject.");
 
                byte[] retBytes;
                retBytes = new byte[CONTENT_LENGTH];
                final XROSRLGSubobject specObj = (XROSRLGSubobject) objToSerialize;
 
-               ByteArray.copyWhole(ByteArray.intToBytes((int) specObj.getSrlgId().getValue()), retBytes, SRLG_ID_NUMBER_OFFSET);
+               // ByteArray.copyWhole(ByteArray.intToBytes((int) specObj.getSrlgId().getValue()), retBytes,
+               // SRLG_ID_NUMBER_OFFSET);
                retBytes[ATTRIBUTE_OFFSET] = (byte) XROSubobjectAttributeMapping.getInstance().getFromAttributeEnum(specObj.getAttribute());
 
                return retBytes;
index c6589cee98836a67082b84810d00d98a93e13fdf..cd1e989a99138aa5235380c497e8c67a9c9f0082 100644 (file)
@@ -18,7 +18,6 @@ import java.util.List;
 import org.junit.Test;
 import org.opendaylight.protocol.concepts.Ipv4Util;
 import org.opendaylight.protocol.concepts.Ipv6Util;
-import org.opendaylight.protocol.concepts.SharedRiskLinkGroup;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.impl.subobject.EROAsNumberSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.EROIpPrefixSubobjectParser;
@@ -41,7 +40,6 @@ import org.opendaylight.protocol.pcep.subobject.RROWavebandSwitchingLabelSubobje
 import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
 import org.opendaylight.protocol.pcep.subobject.XROAsNumberSubobject;
 import org.opendaylight.protocol.pcep.subobject.XROIPPrefixSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROSRLGSubobject;
 import org.opendaylight.protocol.pcep.subobject.XROSubobjectAttribute;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
@@ -144,7 +142,7 @@ public class PCEPSubobjectParserTest {
                objsToTest.add(new XROAsNumberSubobject(new AsNumber((long) 0x1234), true));
                // objsToTest.add(new XROUnnumberedInterfaceSubobject(new IPv4Address(this.ipv4bytes1), new
                // UnnumberedInterfaceIdentifier(0xFFFFFFFFL), true, XROSubobjectAttribute.SRLG));
-               objsToTest.add(new XROSRLGSubobject(new SharedRiskLinkGroup(0x12345678L), false));
+               // objsToTest.add(new XROSRLGSubobject(new SharedRiskLinkGroup(0x12345678L), false));
 
                // assertEquals(objsToTest, PCEPXROSubobjectParser.parse(PCEPXROSubobjectParser.put(objsToTest)));
        }
index 65c9d74b218b667b473ee383e5c60728d5a81dd3..74f645ae6126731b422d3788c0bf5fac1de4e6d0 100644 (file)
@@ -16,7 +16,6 @@ import java.util.List;
 import org.junit.Test;
 import org.opendaylight.protocol.concepts.Ipv4Util;
 import org.opendaylight.protocol.concepts.Ipv6Util;
-import org.opendaylight.protocol.concepts.SharedRiskLinkGroup;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.impl.subobject.XROAsNumberSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.XROIPv4PrefixSubobjectParser;
@@ -25,7 +24,6 @@ import org.opendaylight.protocol.pcep.impl.subobject.XROUnnumberedInterfaceSubob
 import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
 import org.opendaylight.protocol.pcep.subobject.XROAsNumberSubobject;
 import org.opendaylight.protocol.pcep.subobject.XROIPPrefixSubobject;
-import org.opendaylight.protocol.pcep.subobject.XROSRLGSubobject;
 import org.opendaylight.protocol.pcep.subobject.XROSubobjectAttribute;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
@@ -52,7 +50,7 @@ public class PCEPXROSubobjectParserTest {
                // (byte) 0, (byte) 0,
                // (byte) 0x20 }), new UnnumberedInterfaceIdentifier(0x1234L), false, XROSubobjectAttribute.SRLG));
                assertEquals(objsToTest.get(3), new XROAsNumberSubobject(new AsNumber((long) 0x1234), false));
-               assertEquals(objsToTest.get(4), new XROSRLGSubobject(new SharedRiskLinkGroup(0x12345678L), false));
+               // assertEquals(objsToTest.get(4), new XROSRLGSubobject(new SharedRiskLinkGroup(0x12345678L), false));
 
                // assertArrayEquals(bytesFromFile, PCEPXROSubobjectParser.put(objsToTest));