org.jpmml.model.visitors.FloatInterner Maven / Gradle / Ivy
/*
* Copyright (c) 2019 Villu Ruusmann
*/
package org.jpmml.model.visitors;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
*
* A Visitor that interns {@link Float} attribute values.
*
*/
public class FloatInterner extends NumberInterner {
public FloatInterner(){
super(Float.class, FloatInterner.CACHE_PROVIDER.get());
}
@Override
public Float canonicalize(Float value){
return value;
}
static
public void clear(){
FloatInterner.cache.clear();
}
private static final ConcurrentMap cache = new ConcurrentHashMap<>();
public static final ThreadLocal> CACHE_PROVIDER = new ThreadLocal>(){
@Override
public ConcurrentMap initialValue(){
return FloatInterner.cache;
}
};
}