1 /* Copyright 2002-2024 CS GROUP 2 * Licensed to CS GROUP (CS) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * CS licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.orekit.errors; 18 19 import java.util.List; 20 21 import org.orekit.utils.ParameterDriver; 22 import org.orekit.utils.ParameterDriversProvider; 23 24 /** Exception for unsupported {@link ParameterDriver} in a model implementing {@link ParameterDriversProvider}. 25 * 26 * @author Maxime Journot 27 * @author Luc Maisonobe 28 * @since 12.0 29 */ 30 public class UnsupportedParameterException extends OrekitException { 31 32 /** String for empty parameter drivers' list. */ 33 public static final String NO_PARAMETER = "<none>"; 34 35 /** Comma separator for printing list of supported parameter drivers. */ 36 public static final String COMMA_SEP = ", "; 37 38 /** Serializable UID. */ 39 private static final long serialVersionUID = -1363569710782876135L; 40 41 /** Constructor. 42 * 43 * @param parameterName name of the parameter driver that is not supported by the model 44 * @param parameterDrivers list of the model's parameter drivers 45 */ 46 public UnsupportedParameterException(final String parameterName, final List<ParameterDriver> parameterDrivers) { 47 super(OrekitMessages.UNSUPPORTED_PARAMETER_NAME, parameterName, getSupportedNames(parameterDrivers)); 48 } 49 50 /** Builder for the supported parameters' names. 51 * 52 * @param parameterDrivers list of model parameter drivers 53 * @return supported parameter names as a String 54 */ 55 private static String getSupportedNames(final List<ParameterDriver> parameterDrivers) { 56 final StringBuilder builder = new StringBuilder(); 57 for (final ParameterDriver driver : parameterDrivers) { 58 if (builder.length() > 0) { 59 builder.append(COMMA_SEP); 60 } 61 builder.append(driver.getName()); 62 } 63 if (builder.length() == 0) { 64 builder.append(NO_PARAMETER); 65 } 66 return builder.toString(); 67 } 68 }