|
| 1 | +/* |
| 2 | + * © 2021. TU Dortmund University, |
| 3 | + * Institute of Energy Systems, Energy Efficiency and Energy Economics, |
| 4 | + * Research group Distribution grid planning and operation |
| 5 | +*/ |
| 6 | +package edu.ie3.datamodel.utils.validation; |
| 7 | + |
| 8 | +import edu.ie3.datamodel.exceptions.InvalidEntityException; |
| 9 | +import edu.ie3.datamodel.exceptions.ValidationException; |
| 10 | +import edu.ie3.datamodel.models.input.EmInput; |
| 11 | +import edu.ie3.datamodel.utils.Try; |
| 12 | +import java.util.ArrayList; |
| 13 | +import java.util.List; |
| 14 | + |
| 15 | +public class EnergyManagementValidationUtils extends ValidationUtils { |
| 16 | + |
| 17 | + /** Private Constructor as this class is not meant to be instantiated */ |
| 18 | + private EnergyManagementValidationUtils() { |
| 19 | + throw new IllegalStateException("Don't try and instantiate a Utility class."); |
| 20 | + } |
| 21 | + |
| 22 | + /** |
| 23 | + * Validates a energy management unit if: |
| 24 | + * |
| 25 | + * <ul> |
| 26 | + * <li>its control strategy is not null |
| 27 | + * </ul> |
| 28 | + * |
| 29 | + * A "distribution" method, that forwards the check request to specific implementations to fulfill |
| 30 | + * the checking task, based on the class of the given object. |
| 31 | + * |
| 32 | + * @param energyManagement EmInput to validate |
| 33 | + * @return a list of try objects either containing an {@link ValidationException} or an empty |
| 34 | + * Success |
| 35 | + */ |
| 36 | + protected static List<Try<Void, ? extends ValidationException>> check(EmInput energyManagement) { |
| 37 | + List<Try<Void, ? extends ValidationException>> exceptions = new ArrayList<>(); |
| 38 | + |
| 39 | + exceptions.add( |
| 40 | + Try.ofVoid( |
| 41 | + energyManagement.getControlStrategy() == null, |
| 42 | + () -> |
| 43 | + new InvalidEntityException( |
| 44 | + "No control strategy of energy management defined for", energyManagement))); |
| 45 | + |
| 46 | + return exceptions; |
| 47 | + } |
| 48 | +} |
0 commit comments