001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel.component.bean; 018 019import java.lang.reflect.Method; 020 021/** 022 * A key used for caching {@link BeanInfo} by the {@link BeanComponent} 023 */ 024public final class BeanInfoCacheKey { 025 026 private final Class<?> type; 027 private final Method explicitMethod; 028 029 public BeanInfoCacheKey(Class<?> type, Method explicitMethod) { 030 this.type = type; 031 this.explicitMethod = explicitMethod; 032 } 033 034 @Override 035 public boolean equals(Object o) { 036 if (this == o) { 037 return true; 038 } 039 if (o == null || getClass() != o.getClass()) { 040 return false; 041 } 042 043 BeanInfoCacheKey that = (BeanInfoCacheKey) o; 044 045 if (explicitMethod != null ? !explicitMethod.equals(that.explicitMethod) : that.explicitMethod != null) { 046 return false; 047 } 048 if (!type.equals(that.type)) { 049 return false; 050 } 051 052 return true; 053 } 054 055 @Override 056 public int hashCode() { 057 int result = type.hashCode(); 058 result = 31 * result + (explicitMethod != null ? explicitMethod.hashCode() : 0); 059 return result; 060 } 061}