From 444b3272355c61a6ce3a1be3de01b6263e576b4f Mon Sep 17 00:00:00 2001 From: Leclerc Clement Date: Mon, 9 Dec 2024 14:38:56 +0100 Subject: [PATCH] add Exception for null equipement Signed-off-by: Leclerc Clement --- .../ucte/converter/AbstractNamingStrategy.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/AbstractNamingStrategy.java b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/AbstractNamingStrategy.java index b146899fba4..f7c9067ed9a 100644 --- a/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/AbstractNamingStrategy.java +++ b/ucte/ucte-converter/src/main/java/com/powsybl/ucte/converter/AbstractNamingStrategy.java @@ -7,6 +7,7 @@ */ package com.powsybl.ucte.converter; +import com.powsybl.commons.PowsyblException; import com.powsybl.iidm.network.*; import com.powsybl.ucte.converter.util.UcteConverterConstants; import com.powsybl.ucte.network.UcteElementId; @@ -36,6 +37,9 @@ public UcteNodeCode getUcteNodeCode(String id) { @Override public UcteNodeCode getUcteNodeCode(Bus bus) { + if(bus == null) { + throw new PowsyblException("the bus is null"); + } return getUcteNodeCode(bus.getId()); } @@ -55,16 +59,25 @@ public UcteElementId getUcteElementId(String id) { @Override public UcteElementId getUcteElementId(Switch sw) { + if(sw == null) { + throw new PowsyblException("the bus is null"); + } return getUcteElementId(sw.getId()); } @Override public UcteElementId getUcteElementId(Branch branch) { + if(branch == null) { + throw new PowsyblException("the bus is null"); + } return getUcteElementId(branch.getId()); } @Override public UcteElementId getUcteElementId(DanglingLine danglingLine) { + if(danglingLine == null) { + throw new PowsyblException("the bus is null"); + } return getUcteElementId(danglingLine.getId()); } }