/**
* Version number for serialization.
*/
- private static final long serialVersionUID = -5494415245844633625L;
+ private static final long serialVersionUID = -4217150774548362963L;
/**
* The name of the
return builder;
}
+ /**
+ * Determine whether all components in the given path equal to components
+ * in this object or not.
+ *
+ * @param path An object to be compared.
+ * @return {@code true} if all path components in {@code path} are
+ * identical to components in this object.
+ * Otherwise {@code false}.
+ */
+ protected final boolean equalsPath(VBridgeIfPath path) {
+ if (!equalsPath((VBridgePath)path)) {
+ return false;
+ }
+
+ if (ifName == null) {
+ return (path.ifName == null);
+ }
+
+ return ifName.equals(path.ifName);
+ }
+
/**
* Determine whether the given object is identical to this object.
*
* <ul>
* <li>
* {@code o} is a {@code VBridgeIfPath} object.
+ * Note that this method returns {@code false} if {@code o} is an
+ * object of subclass of {@code VBridgeIfPath}.
* </li>
* <li>
* The following values stored in {@code o} are the same as in this
if (o == this) {
return true;
}
- if (!(o instanceof VBridgeIfPath) || !super.equals(o)) {
+ if (o == null || !o.getClass().equals(VBridgeIfPath.class)) {
return false;
}
- VBridgeIfPath path = (VBridgeIfPath)o;
- if (ifName == null) {
- return (path.ifName == null);
- }
-
- return ifName.equals(path.ifName);
+ return equalsPath((VBridgeIfPath)o);
}
/**
/**
* Version number for serialization.
*/
- private static final long serialVersionUID = 49188209943135523L;
+ private static final long serialVersionUID = -8958896997703009257L;
/**
* The name of the
return builder;
}
+ /**
+ * Determine whether all components in the given path equal to components
+ * in this object or not.
+ *
+ * @param path An object to be compared.
+ * @return {@code true} if all path components in {@code path} are
+ * identical to components in this object.
+ * Otherwise {@code false}.
+ */
+ protected final boolean equalsPath(VBridgePath path) {
+ if (!equalsPath((VTenantPath)path)) {
+ return false;
+ }
+
+ if (bridgeName == null) {
+ return (path.bridgeName == null);
+ }
+
+ return bridgeName.equals(path.bridgeName);
+ }
+
/**
* Determine whether the given object is identical to this object.
*
* <ul>
* <li>
* {@code o} is a {@code VBridgePath} object.
+ * Note that this method returns {@code false} if {@code o} is an
+ * object of subclass of {@code VBridgePath}.
* </li>
* <li>
* The following values stored in {@code o} are the same as in this
if (o == this) {
return true;
}
- if (!(o instanceof VBridgePath) || !super.equals(o)) {
+ if (o == null || !o.getClass().equals(VBridgePath.class)) {
return false;
}
- VBridgePath path = (VBridgePath)o;
- if (bridgeName == null) {
- return (path.bridgeName == null);
- }
-
- return bridgeName.equals(path.bridgeName);
+ return equalsPath((VBridgePath)o);
}
/**
/**
* Version number for serialization.
*/
- private static final long serialVersionUID = 5295435248672675596L;
+ private static final long serialVersionUID = 6666863891351658965L;
/**
* The name of the {@linkplain <a href="package-summary.html#VTN">VTN</a>}.
return new StringBuilder(name);
}
+ /**
+ * Determine whether all components in the given path equal to components
+ * in this object or not.
+ *
+ * @param path An object to be compared.
+ * @return {@code true} if all path components in {@code path} are
+ * identical to components in this object.
+ * Otherwise {@code false}.
+ */
+ protected final boolean equalsPath(VTenantPath path) {
+ if (tenantName == null) {
+ return (path.tenantName == null);
+ }
+
+ return tenantName.equals(path.tenantName);
+ }
+
/**
* Determine whether the given object is identical to this object.
*
* <ul>
* <li>
* {@code o} is a {@code VTenantPath} object.
+ * Note that this method returns {@code false} if {@code o} is an
+ * object of subclass of {@code VTenantPath}.
* </li>
* <li>
* The name of the
if (o == this) {
return true;
}
- if (!(o instanceof VTenantPath)) {
+ if (o == null || !o.getClass().equals(VTenantPath.class)) {
return false;
}
- VTenantPath path = (VTenantPath)o;
- if (tenantName == null) {
- return (path.tenantName == null);
- }
-
- return tenantName.equals(path.tenantName);
+ return equalsPath((VTenantPath)o);
}
/**
/*
- * Copyright (c) 2013 NEC Corporation
+ * Copyright (c) 2013-2014 NEC Corporation
* All rights reserved.
*
* This program and the accompanying materials are made available under the
List<String> bnames = createStrings("bridge");
List<String> inames = createStrings("ifname");
for (String tname: tnames) {
+ VTenantPath tpath = new VTenantPath(tname);
for (String bname: bnames) {
+ VBridgePath bpath = new VBridgePath(tname, bname);
for (String iname: inames) {
VBridgeIfPath p1 = new VBridgeIfPath(tname, bname, iname);
VBridgeIfPath p2 =
new VBridgeIfPath(copy(tname), copy(bname),
copy(iname));
testEquals(set, p1, p2);
+
+ // A instance of VTenantPath and VBridgePath must be
+ // treated as different object even if it has the same
+ // path component.
+ assertFalse(tpath.equals(p1));
+ assertFalse(p1.equals(tpath));
+ assertFalse(bpath.equals(p1));
+ assertFalse(p1.equals(bpath));
}
}
}
/*
- * Copyright (c) 2013 NEC Corporation
+ * Copyright (c) 2013-2014 NEC Corporation
* All rights reserved.
*
* This program and the accompanying materials are made available under the
List<String> tnames = createStrings("tenant");
List<String> bnames = createStrings("bridge");
for (String tname: tnames) {
+ VTenantPath tpath = new VTenantPath(tname);
for (String bname: bnames) {
VBridgePath p1 = new VBridgePath(tname, bname);
VBridgePath p2 = new VBridgePath(copy(tname), copy(bname));
testEquals(set, p1, p2);
+
+ // VTenantPath object that has the same tenant name must be
+ // treated as different object.
+ assertFalse(p1.equals(tpath));
+ assertFalse(tpath.equals(p1));
}
}
/*
- * Copyright (c) 2013 NEC Corporation
+ * Copyright (c) 2013-2014 NEC Corporation
* All rights reserved.
*
* This program and the accompanying materials are made available under the
/**
* Version number for serialization.
*/
- private static final long serialVersionUID = 556981779172308505L;
+ private static final long serialVersionUID = -5858869883027125836L;
/**
* Identifier of the VLAN mapping.
return builder;
}
+ /**
+ * Determine whether all components in the given path equal to components
+ * in this object or not.
+ *
+ * @param path An object to be compared.
+ * @return {@code true} if all path components in {@code path} are
+ * identical to components in this object.
+ * Otherwise {@code false}.
+ */
+ protected final boolean equalsPath(VlanMapPath path) {
+ if (!equalsPath((VBridgePath)path)) {
+ return false;
+ }
+
+ return mapId.equals(path.mapId);
+ }
+
/**
* Determine whether the given object is identical to this object.
*
if (o == this) {
return true;
}
- if (!(o instanceof VlanMapPath) || !super.equals(o)) {
+ if (o == null || !o.getClass().equals(VlanMapPath.class)) {
return false;
}
- VlanMapPath path = (VlanMapPath)o;
- return mapId.equals(path.mapId);
+ return equalsPath((VlanMapPath)o);
}
/**
/*
- * Copyright (c) 2013 NEC Corporation
+ * Copyright (c) 2013-2014 NEC Corporation
* All rights reserved.
*
* This program and the accompanying materials are made available under the
import org.junit.Test;
+import org.opendaylight.vtn.manager.VTenantPath;
import org.opendaylight.vtn.manager.VBridgePath;
import org.opendaylight.vtn.manager.VBridgeIfPath;
import org.opendaylight.vtn.manager.internal.TestBase;
List<String> bnames = createStrings("bridge");
List<String> mapIds = createStrings("mapId", false);
for (String tname: tnames) {
+ VTenantPath tpath = new VTenantPath(tname);
for (String bname: bnames) {
VBridgePath bp1 = new VBridgePath(tname, bname);
VBridgePath bp2 = new VBridgePath(copy(tname), copy(bname));
ifPath.equals(p1));
assertFalse("(p2)" + p2.toString() + ",(ifPath)" + ifPath.toString(),
ifPath.equals(p2));
+
+ // A instance of VTenantPath, VBridgePath must be treated
+ // as different object even if it has the same path
+ // component.
+ assertFalse(p1.equals(tpath));
+ assertFalse(tpath.equals(p1));
+
+ assertFalse(p1.equals(bp1));
+ assertFalse(bp1.equals(p1));
}
}
}