Class Defaults
java.lang.Object
org.opentrafficsim.core.definitions.Defaults
- Direct Known Subclasses:
DefaultsNl
This class houses defaults instances for different types, such as GTU types and link types. The static fields should only be
accessed in the setup of a simulation. The simulation itself should be fed the relevant types, and not assume any specific or
more generic super type. Only in this way can simulations be run with entirely different type structures.
Copyright (c) 2022-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static <T> T
Returns a default value of a type, indicated by its name.static <T> T
Returns a default value of a type, indicated by its name.Returns the locale.
-
Field Details
-
NL
Defaults for locale nl_NL.
-
-
Constructor Details
-
Defaults
Constructor.- Parameters:
locale
- Locale; locale.
-
-
Method Details
-
getLocale
Returns the locale.- Returns:
- Locale; locale.
-
getByName
Returns a default value of a type, indicated by its name. This should only be used by parsers. Simulations defined in code should access the relevant static fields directly for code maintainability.- Type Parameters:
T
- type of the value.- Parameters:
clazz
- Class<T>; class instance of type T.name
- String; name referring to a default through static field names, e.g. "NL.VEHICLE".- Returns:
- T; returned default value,
null
if the default could not be found.
-
getByName
protected static <T> T getByName(Class<? extends Defaults> defaultsClass, Class<T> clazz, String name) Returns a default value of a type, indicated by its name. This should only be used by parsers. Simulations defined in code should access the relevant static fields directly for code maintainability.- Type Parameters:
T
- type of the value.- Parameters:
defaultsClass
- Class<? extends Defaults>; defaults class.clazz
- Class<T>; class instance of type T.name
- String; name referring to a default through static field names, e.g. "NL.VEHICLE".- Returns:
- T; returned default value,
null
if the default could not be found.
-