001/* 002 * Copyright 2018 Anyware Services 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.ametys.web.frontoffice.search.metamodel; 017 018import java.util.HashMap; 019import java.util.Map; 020 021/** 022 * This class holds the current values of the additional parameters 023 */ 024public class AdditionalParameterValueMap 025{ 026 private Map<String, Object> _values; 027 028 /** 029 * Builds an AdditionalParameterValueMap 030 * @param values The values 031 */ 032 protected AdditionalParameterValueMap(Map<String, Object> values) 033 { 034 _values = new HashMap<>(values); 035 } 036 037 /** 038 * Gets the value of the given additional parameter 039 * @param <T> the type of the value 040 * @param parameterId The id of the parameter 041 * @return the value of the given additional parameter 042 * @throws ClassCastException if the value cannot be cast to the expected type 043 */ 044 public <T> T getValue(String parameterId) throws ClassCastException 045 { 046 @SuppressWarnings("unchecked") 047 T value = (T) _values.get(parameterId); 048 return value; 049 } 050}