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