source: src/main/java/agents/anac/y2019/harddealer/math3/ode/AbstractParameterizable.java

Last change on this file was 200, checked in by Katsuhide Fujita, 5 years ago

Add ANAC 2019 agents

  • Property svn:executable set to *
File size: 2.5 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF 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 */
17package agents.anac.y2019.harddealer.math3.ode;
18
19import java.util.ArrayList;
20import java.util.Collection;
21
22/** This abstract class provides boilerplate parameters list.
23 *
24 * @since 3.0
25 */
26
27public abstract class AbstractParameterizable implements Parameterizable {
28
29 /** List of the parameters names. */
30 private final Collection<String> parametersNames;
31
32 /** Simple constructor.
33 * @param names names of the supported parameters
34 */
35 protected AbstractParameterizable(final String ... names) {
36 parametersNames = new ArrayList<String>();
37 for (final String name : names) {
38 parametersNames.add(name);
39 }
40 }
41
42 /** Simple constructor.
43 * @param names names of the supported parameters
44 */
45 protected AbstractParameterizable(final Collection<String> names) {
46 parametersNames = new ArrayList<String>();
47 parametersNames.addAll(names);
48 }
49
50 /** {@inheritDoc} */
51 public Collection<String> getParametersNames() {
52 return parametersNames;
53 }
54
55 /** {@inheritDoc} */
56 public boolean isSupported(final String name) {
57 for (final String supportedName : parametersNames) {
58 if (supportedName.equals(name)) {
59 return true;
60 }
61 }
62 return false;
63 }
64
65 /** Check if a parameter is supported and throw an IllegalArgumentException if not.
66 * @param name name of the parameter to check
67 * @exception UnknownParameterException if the parameter is not supported
68 * @see #isSupported(String)
69 */
70 public void complainIfNotSupported(final String name)
71 throws UnknownParameterException {
72 if (!isSupported(name)) {
73 throw new UnknownParameterException(name);
74 }
75 }
76
77}
Note: See TracBrowser for help on using the repository browser.