001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.commons.jcs.jcache.cdi; 020 021import javax.cache.annotation.GeneratedCacheKey; 022import java.util.Arrays; 023 024public class GeneratedCacheKeyImpl implements GeneratedCacheKey 025{ 026 private final Object[] params; 027 private final int hash; 028 029 public GeneratedCacheKeyImpl(final Object[] parameters) 030 { 031 this.params = parameters; 032 this.hash = Arrays.deepHashCode(parameters); 033 } 034 035 @Override 036 public boolean equals(final Object o) 037 { 038 if (this == o) 039 { 040 return true; 041 } 042 if (o == null || getClass() != o.getClass()) 043 { 044 return false; 045 } 046 final GeneratedCacheKeyImpl that = GeneratedCacheKeyImpl.class.cast(o); 047 return Arrays.deepEquals(params, that.params); 048 049 } 050 051 @Override 052 public int hashCode() 053 { 054 return hash; 055 } 056}