001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.rest.server.httppart;
018
019import static org.apache.juneau.commons.httppart.HttpPartType.*;
020
021import java.lang.reflect.*;
022import java.util.regex.*;
023
024import org.apache.juneau.http.HttpPart;
025import org.apache.juneau.marshall.*;
026import org.apache.juneau.marshall.httppart.*;
027import org.apache.juneau.rest.server.*;
028
029/**
030 * Represents a single query parameter on an HTTP request.
031 *
032 * <p>
033 * Typically accessed through the {@link RequestQueryParamList} class.
034 *
035 * <p>
036 *    Some important methods on this class are:
037 * </p>
038 * <ul class='javatree'>
039 *    <li class='jc'>{@link RequestQueryParam}
040 *    <ul class='spaced-list'>
041 *       <li>Methods for retrieving simple string values:
042 *       <ul class='javatreec'>
043 *          <li class='jm'>{@link RequestQueryParam#asString() asString()}
044 *          <li class='jm'>{@link RequestQueryParam#get() get()}
045 *          <li class='jm'>{@link RequestQueryParam#isPresent() isPresent()}
046 *          <li class='jm'>{@link RequestQueryParam#orElse(String) orElse(String)}
047 *       </ul>
048 *       <li>Methods for retrieving as other common types:
049 *       <ul class='javatreec'>
050 *          <li class='jm'>{@link RequestQueryParam#asBoolean() asBoolean()}
051 *          <li class='jm'>{@link RequestQueryParam#asBooleanPart() asBooleanPart()}
052 *          <li class='jm'>{@link RequestQueryParam#asCsvArray() asCsvArray()}
053 *          <li class='jm'>{@link RequestQueryParam#asCsvArrayPart() asCsvArrayPart()}
054 *          <li class='jm'>{@link RequestQueryParam#asDate() asDate()}
055 *          <li class='jm'>{@link RequestQueryParam#asDatePart() asDatePart()}
056 *          <li class='jm'>{@link RequestQueryParam#asInteger() asInteger()}
057 *          <li class='jm'>{@link RequestQueryParam#asIntegerPart() asIntegerPart()}
058 *          <li class='jm'>{@link RequestQueryParam#asLong() asLong()}
059 *          <li class='jm'>{@link RequestQueryParam#asLongPart() asLongPart()}
060 *          <li class='jm'>{@link RequestQueryParam#asMatcher(Pattern) asMatcher(Pattern)}
061 *          <li class='jm'>{@link RequestQueryParam#asMatcher(String) asMatcher(String)}
062 *          <li class='jm'>{@link RequestQueryParam#asMatcher(String,int) asMatcher(String,int)}
063 *          <li class='jm'>{@link RequestQueryParam#asStringPart() asStringPart()}
064 *          <li class='jm'>{@link RequestQueryParam#asUriPart() asUriPart()}
065 *       </ul>
066 *       <li>Methods for retrieving as custom types:
067 *       <ul class='javatreec'>
068 *          <li class='jm'>{@link RequestQueryParam#as(Class) as(Class)}
069 *          <li class='jm'>{@link RequestQueryParam#as(ClassMeta) as(ClassMeta)}
070 *          <li class='jm'>{@link RequestQueryParam#as(Type,Type...) as(Type,Type...)}
071 *          <li class='jm'>{@link RequestQueryParam#parser(HttpPartParserSession) parser(HttpPartParserSession)}
072 *          <li class='jm'>{@link RequestQueryParam#schema(HttpPartSchema) schema(HttpPartSchema)}
073 *       </ul>
074 *       <li>Methods for performing assertion checks:
075 *       <ul class='javatreec'>
076 *          <li class='jm'>{@link RequestQueryParam#assertCsvArray() assertCsvArray()}
077 *          <li class='jm'>{@link RequestQueryParam#assertDate() assertDate()}
078 *          <li class='jm'>{@link RequestQueryParam#assertInteger() assertInteger()}
079 *          <li class='jm'>{@link RequestQueryParam#assertLong() assertLong()}
080 *          <li class='jm'>{@link RequestQueryParam#assertString() assertString()}
081 *       </ul>
082 *       <li>Other methods:
083 *       <ul class='javatreec'>
084 *          <li class='jm'>{@link RequestQueryParam#getName() getName()}
085 *          <li class='jm'>{@link RequestQueryParam#getValue() getValue()}
086 *       </ul>
087 *    </ul>
088 * </ul>
089 *
090 * <h2 class='section'>See Also:</h2><ul>
091 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/RestServerHttpParts">HTTP parts in REST servers</a>
092 * </ul>
093 */
094public class RequestQueryParam extends RequestHttpPart implements HttpPart {
095
096   /**
097    * Constructor.
098    *
099    * @param request The request object.
100    * @param name The parameter name.
101    * @param value The parameter value.
102    */
103   public RequestQueryParam(RestRequest request, String name, String value) {
104      super(QUERY, request, name, value);
105   }
106
107   @Override /* Overridden from RequestHttpPart */
108   public RequestQueryParam def(String def) {
109      super.def(def);
110      return this;
111   }
112
113   @Override /* Overridden from RequestHttpPart */
114   public RequestQueryParam parser(HttpPartParserSession value) {
115      super.parser(value);
116      return this;
117   }
118
119   @Override /* Overridden from RequestHttpPart */
120   public RequestQueryParam schema(HttpPartSchema value) {
121      super.schema(value);
122      return this;
123   }
124}