001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.svl;
014
015import org.apache.juneau.*;
016
017/**
018 * Subclass of an {@link ObjectMap} that automatically resolves any SVL variables in values.
019 *
020 * <p>
021 * Resolves variables in the following values:
022 * <ul>
023 *    <li>Values of type {@link CharSequence}.
024 *    <li>Arrays containing values of type {@link CharSequence}.
025 *    <li>Collections containing values of type {@link CharSequence}.
026 *    <li>Maps containing values of type {@link CharSequence}.
027 * </ul>
028 *
029 * <p>
030 * All other data types are left as-is.
031 *
032 * <h5 class='section'>See Also:</h5>
033 * <ul>
034 *    <li class='link'>{@doc juneau-svl.SvlVariables}
035 * </ul>
036 */
037@SuppressWarnings({"serial"})
038public class ResolvingObjectMap extends ObjectMap {
039
040   private final VarResolverSession varResolver;
041
042   /**
043    * Constructor.
044    *
045    * @param varResolver The var resolver session to use for resolving SVL variables.
046    */
047   public ResolvingObjectMap(VarResolverSession varResolver) {
048      super();
049      this.varResolver = varResolver;
050   }
051
052   @Override /* Map */
053   public Object get(Object key) {
054      return varResolver.resolve(super.get(key));
055   }
056}