public static FiberConnection getFiberConnection(
      FiberConnection connection, ProteusOpticalSwitch switchModel) {

    FiberConnection matchingConnection = null;

    for (FiberConnection existentConnection : switchModel.getFiberConnections()) {
      if ( // same cards
      existentConnection.getSrcCard().getChasis() == connection.getSrcCard().getChasis()
          && existentConnection.getSrcCard().getModuleNumber()
              == connection.getSrcCard().getModuleNumber()
          && existentConnection.getDstCard().getChasis() == connection.getDstCard().getChasis()
          && existentConnection.getDstCard().getModuleNumber()
              == connection.getDstCard().getModuleNumber()
          &&
          // same ports
          existentConnection.getSrcPort().getPortNumber() == connection.getSrcPort().getPortNumber()
          && existentConnection.getDstPort().getPortNumber()
              == connection.getDstPort().getPortNumber()
          &&
          // same channels
          existentConnection.getSrcFiberChannel().getLambda()
              == connection.getSrcFiberChannel().getLambda()
          && existentConnection.getDstFiberChannel().getLambda()
              == connection.getDstFiberChannel().getLambda()) {
        matchingConnection = existentConnection;
        break;
      }
    }

    return matchingConnection;
  }
  private FiberConnection newMakeConnectionParams(ProteusOpticalSwitch proteus) throws Exception {

    FiberConnection fiberConnection = new FiberConnection();

    // PSROADM DROP card
    int dropChasis = 0;
    int dropSlot = 1;
    ProteusOpticalSwitchCard dropCard = proteus.getCard(dropChasis, dropSlot);
    FCPort srcPort = (FCPort) dropCard.getPort(0);

    DWDMChannel srcFiberChannel =
        (DWDMChannel)
            ((WDMChannelPlan) dropCard.getChannelPlan())
                .getChannel(dropCard.getChannelPlan().getFirstChannel());

    double srcLambda = srcFiberChannel.getLambda();

    fiberConnection.setSrcCard(dropCard);
    fiberConnection.setSrcPort(srcPort);
    fiberConnection.setSrcFiberChannel(srcFiberChannel);

    // PSROADM ADD card
    int addChasis = 0;
    int addSlot = 17;
    ProteusOpticalSwitchCard addCard = proteus.getCard(addChasis, addSlot);
    FCPort dstPort = ((WonesysPassiveAddCard) addCard).getCommonPort();

    DWDMChannel dstFiberChannel =
        (DWDMChannel)
            ((WDMChannelPlan) addCard.getChannelPlan())
                .getChannel(
                    ((WDMChannelPlan) addCard.getChannelPlan())
                        .getChannelNumberFromLambda(srcLambda));

    fiberConnection.setDstCard(addCard);
    fiberConnection.setDstPort(dstPort);
    fiberConnection.setDstFiberChannel(dstFiberChannel);

    return fiberConnection;
  }