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.collections.*;
016
017/**
018 * Subclass of an {@link JsonMap} 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><ul>
033 *    <li class='link'><a class="doclink" href="../../../../index.html#jm.SimpleVariableLanguage">Simple Variable Language</a>
034 * </ul>
035 */
036@SuppressWarnings({"serial"})
037public class ResolvingJsonMap extends JsonMap {
038
039   private final VarResolverSession varResolver;
040
041   /**
042    * Constructor.
043    *
044    * @param varResolver The var resolver session to use for resolving SVL variables.
045    */
046   public ResolvingJsonMap(VarResolverSession varResolver) {
047      super();
048      this.varResolver = varResolver;
049   }
050
051   @Override /* Map */
052   public Object get(Object key) {
053      return varResolver.resolve(super.get(key));
054   }
055}