001/** 002 * Copyright (C) 2006-2020 Talend Inc. - www.talend.com 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.talend.sdk.component.server.front.base.internal; 017 018import java.util.Locale; 019import java.util.Objects; 020 021public class RequestKey { 022 023 private final Locale locale; 024 025 private final boolean includeIconContent; 026 027 private final String query; 028 029 private final int cacheHash; 030 031 public RequestKey(final Locale locale, final boolean includeIconContent, final String query) { 032 this.locale = locale; 033 this.includeIconContent = includeIconContent; 034 this.query = query; 035 this.cacheHash = Objects.hash(locale, includeIconContent, query); 036 } 037 038 @Override 039 public boolean equals(final Object o) { 040 if (this == o) { 041 return true; 042 } 043 if (o == null || getClass() != o.getClass()) { 044 return false; 045 } 046 if (!super.equals(o)) { 047 return false; 048 } 049 final RequestKey that = RequestKey.class.cast(o); 050 return Objects.equals(locale, that.locale) && Objects.equals(includeIconContent, that.includeIconContent) 051 && Objects.equals(query, that.query); 052 } 053 054 @Override 055 public int hashCode() { 056 return cacheHash; 057 } 058}