All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fathzer.imt.implementation.ThreadSafeEvaluator Maven / Gradle / Ivy

There is a newer version: 0.0.6
Show newest version
package com.fathzer.imt.implementation;

import com.fathzer.imt.Bitmap;
import com.fathzer.imt.Evaluator;
import com.fathzer.imt.TagsTable;

/** A thread safe evaluator based on {@link ThreadLocal}.
 * @param  The type of the tag class
 */
public abstract class ThreadSafeEvaluator implements Evaluator {
	private ThreadLocal> evaluator = new ThreadLocal>() {
		@Override
		protected Evaluator initialValue() {
			return buildUnsafeEvaluator();
		}
	};
	
	protected abstract Evaluator buildUnsafeEvaluator();
	
	@Override
	public Bitmap evaluate(TagsTable table, String expression, boolean failIfUnknown) {
		return evaluator.get().evaluate(table, expression, (Boolean)failIfUnknown);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy