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