Class ClassInstanceCache
- java.lang.Object
-
- ai.timefold.solver.core.impl.solver.ClassInstanceCache
-
public final class ClassInstanceCache extends Object
Exists so that particular user-provided classes, which are instantiated by Timefold fromSolverConfig, only ever have one instance. Each solver instance needs to get a fresh instance of this class, so that solvers can not share state between them.Case in point,
NearbyDistanceMeter. If two places in the config reference the same implementation of this interface, we can be sure that they represent the same logic. And since it is us who instantiate them and they require no-arg constructors, we can be reasonably certain that they will not contain any context-specific state. Therefore it is safe to have all of these references served by a single instance, allowing for all sorts of beneficial caching. (Such as, in this case, nearby distance matrix caching across the solver.)
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ClassInstanceCachecreate()<T> TnewInstance(Object configBean, String propertyName, Class<T> clazz)
-
-
-
Method Detail
-
create
public static ClassInstanceCache create()
-
-