1 package org.opentrafficsim.road.definitions;
2
3 import java.util.Locale;
4 import java.util.Optional;
5
6 import org.opentrafficsim.core.definitions.Defaults;
7
8 /**
9 * This class houses defaults instances for different types, specific for road, such as lane types. The static fields should
10 * only be accessed in the setup of a simulation. The simulation itself should be fed the relevant types, and not assume any
11 * specific or more generic super type. Only in this way can simulations be run with entirely different type structures.
12 * <p>
13 * Copyright (c) 2022-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
14 * BSD-style license. See <a href="https://opentrafficsim.org/docs/license.html">OpenTrafficSim License</a>.
15 * </p>
16 * @author <a href="https://github.com/averbraeck">Alexander Verbraeck</a>
17 * @author <a href="https://github.com/peter-knoppers">Peter Knoppers</a>
18 * @author <a href="https://github.com/wjschakel">Wouter Schakel</a>
19 */
20 public abstract class DefaultsRoad extends Defaults
21 {
22
23 /** Defaults for locale nl_NL. */
24 public static final DefaultsRoadNl NL = new DefaultsRoadNl();
25
26 /**
27 * Constructor.
28 * @param locale locale.
29 */
30 protected DefaultsRoad(final Locale locale)
31 {
32 super(locale);
33 }
34
35 /**
36 * Returns a default value of a type, indicated by its name. This should only be used by parsers. Simulations defined in
37 * code should access the relevant static fields directly for code maintainability.
38 * @param clazz class instance of type T.
39 * @param name name referring to a default through static field names, e.g. "NL.FREEWAY".
40 * @param <T> type of the value.
41 * @return returned default value, empty if the default could not be found.
42 */
43 public static <T> Optional<T> getByName(final Class<T> clazz, final String name)
44 {
45 return Optional.ofNullable(getByName(DefaultsRoad.class, clazz, name));
46 }
47
48 }