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.urlencoding;
014
015import org.apache.juneau.*;
016import org.apache.juneau.urlencoding.annotation.*;
017
018/**
019 * Metadata on classes specific to the URL-Encoding serializers and parsers pulled from the {@link UrlEncoding @UrlEncoding} annotation on the class.
020 */
021public class UrlEncodingClassMeta extends ExtendedClassMeta {
022
023   private final UrlEncoding urlEncoding;
024   private final boolean expandedParams;
025
026   /**
027    * Constructor.
028    *
029    * @param cm The class that this annotation is defined on.
030    * @param mp URL-encoding metadata provider (for finding information about other artifacts).
031    */
032   public UrlEncodingClassMeta(ClassMeta<?> cm, UrlEncodingMetaProvider mp) {
033      super(cm);
034      this.urlEncoding = cm.getAnnotation(UrlEncoding.class);
035      if (urlEncoding != null) {
036         expandedParams = urlEncoding.expandedParams();
037      } else {
038         expandedParams = false;
039      }
040   }
041
042   /**
043    * Returns the {@link UrlEncoding} annotation defined on the class.
044    *
045    * @return The value of the {@link UrlEncoding} annotation, or <jk>null</jk> if annotation is not specified.
046    */
047   protected UrlEncoding getAnnotation() {
048      return urlEncoding;
049   }
050
051   /**
052    * Returns the {@link UrlEncoding#expandedParams()} annotation defined on the class.
053    *
054    * @return The value of the {@link UrlEncoding#expandedParams()} annotation.
055    */
056   protected boolean isExpandedParams() {
057      return expandedParams;
058   }
059}