@@ -0,0 +1,1568 @@
+/*%0A * All content copyright Terracotta, Inc., unless otherwise indicated.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.terracotta.statistics;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A/**%0A *%0A * @author cdennis%0A */%0Apublic class ConstantValueStatistic%3CT%3E implements ValueStatistic%3CT%3E %7B%0A%0A  private static final Map%3CObject, ValueStatistic%3C?%3E%3E common = new HashMap%3CObject, ValueStatistic%3C?%3E%3E();%0A  static %7B%0A    common.put(Integer.valueOf(0), new ConstantValueStatistic%3CInteger%3E(0));%0A    common.put(Long.valueOf(0L), new ConstantValueStatistic%3CLong%3E(0L));%0A    common.put(null, new ConstantValueStatistic(null));%0A  %7D%0A  %0A  public static %3CT%3E ValueStatistic%3CT%3E instance(T value) %7B%0A    ValueStatistic%3CT%3E interned = (ValueStatistic%3CT%3E) common.get(value);%0A    if (interned == null) %7B%0A      return new ConstantValueStatistic%3CT%3E(value);%0A    %7D else %7B%0A      return interned;%0A    %7D%0A  %7D%0A  %0A  private final T value;%0A  %0A  private ConstantValueStatistic(T value) %7B%0A    this.value = value;%0A  %7D%0A  %0A  @Override%0A  public T value() %7B%0A    return value;%0A  %7D%0A%7D%0A

add constant value statistic impl to function as an interned stand in