Package org.optaplanner.core.config.util
Class ConfigUtils
- java.lang.Object
-
- org.optaplanner.core.config.util.ConfigUtils
-
public class ConfigUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringAVAILABLE_PROCESSOR_COUNTName of the variable that representsRuntime.availableProcessors().
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidapplyCustomProperties(Object bean, String beanClassPropertyName, Map<String,String> customProperties, String customPropertiesPropertyName)static intceilDivide(int dividend, int divisor)Divides and ceils the result without using floating point arithmetic.static Class<? extends Annotation>extractAnnotationClass(Member member, Class<? extends Annotation>... annotationClasses)static Class<?>extractCollectionGenericTypeParameter(String parentClassConcept, Class<?> parentClass, Class<?> type, Type genericType, Class<? extends Annotation> annotationClass, String memberName)static <C> MemberAccessorfindPlanningIdMemberAccessor(Class<C> clazz)static List<Class<?>>getAllAnnotatedLineageClasses(Class<?> bottomClass, Class<? extends Annotation> annotation)static List<Member>getAllMembers(Class<?> baseClass, Class<? extends Annotation> annotationClass)static List<Member>getDeclaredMembers(Class<?> baseClass)static <C extends AbstractConfig<C>>
CinheritConfig(C original, C inherited)static <C extends AbstractConfig<C>>
List<C>inheritMergeableListConfig(List<C> originalList, List<C> inheritedList)static <T> List<T>inheritMergeableListProperty(List<T> originalList, List<T> inheritedList)static <K,T>
Map<K,T>inheritMergeableMapProperty(Map<K,T> originalMap, Map<K,T> inheritedMap)static <T> TinheritOverwritableProperty(T original, T inherited)static booleanisEmptyCollection(Collection<?> collection)static <T> TmeldProperty(T a, T b)A relaxed version ofmergeProperty(Object, Object).static <T> TmergeProperty(T a, T b)static <T> TnewInstance(Object bean, String propertyName, Class<T> clazz)static intresolvePoolSize(String propertyName, String script, org.slf4j.Logger logger, String... magicValues)
-
-
-
Field Detail
-
AVAILABLE_PROCESSOR_COUNT
public static final String AVAILABLE_PROCESSOR_COUNT
Name of the variable that representsRuntime.availableProcessors().- See Also:
- Constant Field Values
-
-
Method Detail
-
applyCustomProperties
public static void applyCustomProperties(Object bean, String beanClassPropertyName, Map<String,String> customProperties, String customPropertiesPropertyName)
-
inheritConfig
public static <C extends AbstractConfig<C>> C inheritConfig(C original, C inherited)
-
inheritMergeableListConfig
public static <C extends AbstractConfig<C>> List<C> inheritMergeableListConfig(List<C> originalList, List<C> inheritedList)
-
inheritOverwritableProperty
public static <T> T inheritOverwritableProperty(T original, T inherited)
-
inheritMergeableListProperty
public static <T> List<T> inheritMergeableListProperty(List<T> originalList, List<T> inheritedList)
-
inheritMergeableMapProperty
public static <K,T> Map<K,T> inheritMergeableMapProperty(Map<K,T> originalMap, Map<K,T> inheritedMap)
-
mergeProperty
public static <T> T mergeProperty(T a, T b)
-
meldProperty
public static <T> T meldProperty(T a, T b)A relaxed version ofmergeProperty(Object, Object). Used primarily for merging failed benchmarks, where a property remains the same over benchmark runs (for example: dataset problem size), but the property in the failed benchmark isn't initialized, therefore null. When merging, we can still use the correctly initialized property of the benchmark that didn't fail.Null-handling:
- if both properties are null, returns null
- if only one of the properties is not null, returns that property
- if both properties are not null, returns
mergeProperty(Object, Object)
- Type Parameters:
T- the type of propertyaandb- Parameters:
a- propertyab- propertyb- Returns:
- sometimes null
- See Also:
mergeProperty(Object, Object)
-
isEmptyCollection
public static boolean isEmptyCollection(Collection<?> collection)
-
ceilDivide
public static int ceilDivide(int dividend, int divisor)Divides and ceils the result without using floating point arithmetic. For floor division, seeMath.floorDiv(long, long).- Parameters:
dividend- the dividenddivisor- the divisor- Returns:
- dividend / divisor, ceiled
- Throws:
ArithmeticException- ifdivisor == 0
-
resolvePoolSize
public static int resolvePoolSize(String propertyName, String script, org.slf4j.Logger logger, String... magicValues)
-
getAllAnnotatedLineageClasses
public static List<Class<?>> getAllAnnotatedLineageClasses(Class<?> bottomClass, Class<? extends Annotation> annotation)
-
getDeclaredMembers
public static List<Member> getDeclaredMembers(Class<?> baseClass)
- Parameters:
baseClass- never null- Returns:
- never null, sorted by type (fields before methods), then by
AlphabeticMemberComparator.
-
getAllMembers
public static List<Member> getAllMembers(Class<?> baseClass, Class<? extends Annotation> annotationClass)
- Parameters:
baseClass- never nullannotationClass- never null- Returns:
- never null, sorted by type (fields before methods), then by
AlphabeticMemberComparator.
-
extractAnnotationClass
@SafeVarargs public static Class<? extends Annotation> extractAnnotationClass(Member member, Class<? extends Annotation>... annotationClasses)
-
extractCollectionGenericTypeParameter
public static Class<?> extractCollectionGenericTypeParameter(String parentClassConcept, Class<?> parentClass, Class<?> type, Type genericType, Class<? extends Annotation> annotationClass, String memberName)
-
findPlanningIdMemberAccessor
public static <C> MemberAccessor findPlanningIdMemberAccessor(Class<C> clazz)
-
-