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.CacheMethodDetails;
022import javax.interceptor.InvocationContext;
023import java.lang.annotation.Annotation;
024import java.lang.reflect.Method;
025import java.util.HashSet;
026import java.util.Set;
027
028import static java.util.Arrays.asList;
029
030public class CacheMethodDetailsImpl<A extends Annotation> implements CacheMethodDetails<A>
031{
032    protected final InvocationContext delegate;
033    private final Set<Annotation> annotations;
034    private final A cacheAnnotation;
035    private final String cacheName;
036    protected final CDIJCacheHelper.MethodMeta meta;
037
038    public CacheMethodDetailsImpl(final InvocationContext delegate, final A cacheAnnotation, final String cacheName,
039                                  final CDIJCacheHelper.MethodMeta meta)
040    {
041        this.delegate = delegate;
042        this.annotations = meta.getAnnotations();
043        this.cacheAnnotation = cacheAnnotation;
044        this.cacheName = cacheName;
045        this.meta = meta;
046    }
047
048    @Override
049    public Method getMethod()
050    {
051        return delegate.getMethod();
052    }
053
054    @Override
055    public Set<Annotation> getAnnotations()
056    {
057        return annotations;
058    }
059
060    @Override
061    public A getCacheAnnotation()
062    {
063        return cacheAnnotation;
064    }
065
066    @Override
067    public String getCacheName()
068    {
069        return cacheName;
070    }
071}