2 * Copyright © 2024 Smartoptics and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.renderer.provisiondevice.transaction;
11 import java.util.List;
12 import java.util.Objects;
13 import org.opendaylight.transportpce.renderer.provisiondevice.transaction.delete.Delete;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Connection transaction.
21 * i.e. a class tracking a connection.
23 public class Connection implements Transaction {
25 private static final Logger LOG = LoggerFactory.getLogger(Connection.class);
26 private final String deviceId;
27 private final String connectionNumber;
28 private final boolean isOtn;
30 public Connection(String deviceId, String connectionNumber, boolean isOtn) {
31 this.deviceId = deviceId;
32 this.connectionNumber = connectionNumber;
37 public boolean rollback(Delete delete) {
38 List<String> supportingInterfaces = delete.deleteCrossConnect(deviceId, connectionNumber, isOtn);
40 if (supportingInterfaces == null || supportingInterfaces.size() == 0) {
44 LOG.info("Supporting interfaces {} affected by rollback on {} {}",
45 String.join(", ", supportingInterfaces), deviceId, connectionNumber);
52 public String description() {
53 return String.format("Connection %s connection number %s isOtn %s", deviceId,
54 connectionNumber, isOtn);
58 public boolean equals(Object object) {
62 if (!(object instanceof Connection)) {
65 Connection that = (Connection) object;
66 return isOtn == that.isOtn && Objects.equals(deviceId, that.deviceId)
67 && Objects.equals(connectionNumber, that.connectionNumber);
71 public int hashCode() {
72 return Objects.hash(deviceId, connectionNumber, isOtn);