gt:         if (voltageLevel == null) {
context: /**
   * Copyright (c) 2016, All partners of the iTesla project (http://www.itesla-project.eu/consortium)
   * This Source Code Form is subject to the terms of the Mozilla Public
   * License, v. 2.0. If a copy of the MPL was not distributed with this
   * file, You can obtain one at http://mozilla.org/MPL/2.0/.
   */
  package com.powsybl.iidm.network.impl;
  
  import com.powsybl.commons.PowsyblException;
  import com.powsybl.iidm.network.Terminal;
  import com.powsybl.iidm.network.ValidationException;
  import com.powsybl.iidm.network.impl.util.Ref;
  import gnu.trove.list.array.TDoubleArrayList;
  import gnu.trove.list.array.TIntArrayList;
  
  import java.util.Optional;
  import java.util.Set;
  
  /**
   * A terminal connected to a node breaker topology.
   *
   * @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
   */
  class NodeTerminal extends AbstractTerminal {
  
      private static final String UNMODIFIABLE_REMOVED_EQUIPMENT = "Cannot modify removed equipment";
  
      private int node;
  
      // attributes depending on the variant
  
      protected final TDoubleArrayList v;
  
      protected final TDoubleArrayList angle;
  
      protected final TIntArrayList connectedComponentNumber;
  
      protected final TIntArrayList synchronousComponentNumber;
  
      private final NodeBreakerView nodeBreakerView = new NodeBreakerView() {
  
          @Override
          public int getNode() {
              return node;
          }
  
          @Override
          public void moveConnectable(int node, String voltageLevelId) {
              if (network == null) {
                  throw new PowsyblException(UNMODIFIABLE_REMOVED_EQUIPMENT);
              }
              getConnectable().move(NodeTerminal.this, getConnectionInfo(), node, voltageLevelId);
          }
      };
  
      private final BusBreakerViewExt busBreakerView = new BusBreakerViewExt() {
  
          @Override
          public BusExt getBus() {
              if (voltageLevel == null) {
                  return null;
              }
              return ((NodeBreakerVoltageLevel) voltageLevel).getCalculatedBusBreakerTopology().getBus(node);
          }
  
          @Override
          public BusExt getConnectableBus() {
              if (voltageLevel == null) {
                  return null;
              }
              return ((NodeBreakerVoltageLevel) voltageLevel).getCalculatedBusBreakerTopology().getConnectableBus(node);
          }
  
          @Override
          public void setConnectableBus(String busId) {
              throw NodeBreakerVoltageLevel.createNotSupportedNodeBreakerTopologyException();
          }
  
          @Override
          public void moveConnectable(String busId, boolean connected) {
              if (network == null) {
                  throw new PowsyblException(UNMODIFIABLE_REMOVED_EQUIPMENT);
              }
              getConnectable().move(NodeTerminal.this, getConnectionInfo(), busId, connected);
          }
  
      };
  
      @Override
      public String getConnectionInfo() {
          return "node " + getNode() + ", Voltage level " + getVoltageLevel().getId();
      }
  
      private final BusViewExt busView = new BusViewExt() {
  
          @Override
          public BusExt getBus() {
              if (voltageLevel == null) {
                  return null;
              }
              return ((NodeBreakerVoltageLevel) voltageLevel).getCalculatedBusTopology().getBus(node);
          }
  
          @Override
          public BusExt getConnectableBus() {
              if (voltageLevel == null) {
                  return null;
              }
              return ((NodeBreakerVoltageLevel) voltageLevel).getCalculatedBusTopology().getConnectableBus(node);
          }
  
      };
  
      NodeTerminal(Ref<? extends VariantManagerHolder> network, int node) {
          super(network);
          this.node = node;
          int variantArraySize = network.get().getVariantManager().getVariantArraySize();
          v = new TDoubleArrayList(variantArraySize);
          angle = new TDoubleArrayList(variantArraySize);
          connectedComponentNumber = new TIntArrayList(variantArraySize);
          synchronousComponentNumber = new TIntArrayList(variantArraySize);
          for (int i = 0; i < variantArraySize; i++) {
              v.add(Double.NaN);
              angle.add(Double.NaN);
              connectedComponentNumber.add(0);
              synchronousComponentNumber.add(0);
          }
      }
  
      protected void notifyUpdate(String attribute, String variantId, Object oldValue, Object newValue) {
          getConnectable().notifyUpdate(attribute, variantId, oldValue, newValue);
      }
  
      public int getNode() {
          return node;
      }
  
      @Override
      protected double getV() {
          return Optional.ofNullable(network).map(n -> v.get(n.get().getVariantIndex())).orElse(Double.NaN);
      }
  
      void setV(double v) {
          if (network == null) {
              throw new PowsyblException(UNMODIFIABLE_REMOVED_EQUIPMENT);
          }
          if (v < 0) {
              throw new ValidationException(connectable, "voltage cannot be < 0");
          }
          int variantIndex = network.get().getVariantIndex();
          double oldValue = this.v.set(variantIndex, v);
          String variantId = network.get().getVariantManager().getVariantId(variantIndex);
          notifyUpdate("v", variantId, oldValue, v);
      }
  
      double getAngle() {
          return Optional.ofNullable(network).map(n -> angle.get(n.get().getVariantIndex())).orElse(Double.NaN);
      }
  
      void setAngle(double angle) {
          if (network == null) {
              throw new PowsyblException(UNMODIFIABLE_REMOVED_EQUIPMENT);
          }
          int variantIndex = network.get().getVariantIndex();
          double oldValue = this.angle.set(variantIndex, angle);
          String variantId = network.get().getVariantManager().getVariantId(variantIndex);
          notifyUpdate("angle", variantId, oldValue, angle);
      }
  
      int getConnectedComponentNumber() {
          return Optional.ofNullable(network).map(n -> connectedComponentNumber.get(n.get().getVariantIndex())).orElse(-1);
      }
  
      void setConnectedComponentNumber(int connectedComponentNumber) {
          if (network == null) {
              throw new PowsyblException(UNMODIFIABLE_REMOVED_EQUIPMENT);
          }
          int variantIndex = network.get().getVariantIndex();
          int oldValue = this.connectedComponentNumber.set(variantIndex, connectedComponentNumber);
          String variantId = network.get().getVariantManager().getVariantId(variantIndex);
          notifyUpdate("connectedComponentNumber", variantId, oldValue, connectedComponentNumber);
      }
  
      int getSynchronousComponentNumber() {
          return Optional.ofNullable(network).map(n -> synchronousComponentNumber.get(n.get().getVariantIndex())).orElse(-1);
      }
  
      void setSynchronousComponentNumber(int componentNumber) {
          if (network == null) {
              throw new PowsyblException(UNMODIFIABLE_REMOVED_EQUIPMENT);
          }
          int variantIndex = network.get().getVariantIndex();
          int oldValue = this.synchronousComponentNumber.set(variantIndex, componentNumber);
          String variantId = network.get().getVariantManager().getVariantId(variantIndex);
          notifyUpdate("synchronousComponentNumber", variantId, oldValue, componentNumber);
      }
  
      @Override
      public NodeBreakerView getNodeBreakerView() {
          return nodeBreakerView;
      }
  
      @Override
      public BusBreakerViewExt getBusBreakerView() {
          return busBreakerView;
      }
  
      @Override
      public BusViewExt getBusView() {
          return busView;
      }
  
      @Override
      public boolean isConnected() {
  