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 ClassMetaExtended {
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    */
031   public UrlEncodingClassMeta(ClassMeta<?> cm) {
032      super(cm);
033      this.urlEncoding = cm.getInfo().getAnnotation(UrlEncoding.class);
034      if (urlEncoding != null) {
035         expandedParams = urlEncoding.expandedParams();
036      } else {
037         expandedParams = false;
038      }
039   }
040
041   /**
042    * Returns the {@link UrlEncoding} annotation defined on the class.
043    *
044    * @return The value of the {@link UrlEncoding} annotation, or <jk>null</jk> if annotation is not specified.
045    */
046   protected UrlEncoding getAnnotation() {
047      return urlEncoding;
048   }
049
050   /**
051    * Returns the {@link UrlEncoding#expandedParams()} annotation defined on the class.
052    *
053    * @return The value of the {@link UrlEncoding#expandedParams()} annotation.
054    */
055   protected boolean isExpandedParams() {
056      return expandedParams;
057   }
058}