1 /*
2 * Copyright 2012-2025 CodeLibs Project and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.codelibs.fess.entity;
17
18 import java.util.Arrays;
19
20 /**
21 * Entity class representing a request parameter with a name and associated values.
22 * This class encapsulates HTTP request parameters that can have multiple values,
23 * such as query parameters, form parameters, or other request-related data.
24 *
25 * <p>This class is immutable and thread-safe. Once created, the parameter name
26 * and values cannot be modified.</p>
27 *
28 */
29 public class RequestParameter {
30
31 /** The name of the request parameter. */
32 private final String name;
33
34 /** The array of values associated with this parameter. */
35 private final String[] values;
36
37 /**
38 * Constructs a new RequestParameter with the specified name and values.
39 *
40 * @param name the name of the parameter, must not be null
41 * @param values the array of values for this parameter, can be null or empty
42 */
43 public RequestParameter(final String name, final String[] values) {
44 this.name = name;
45 this.values = values;
46 }
47
48 /**
49 * Returns the name of this request parameter.
50 *
51 * @return the parameter name
52 */
53 public String getName() {
54 return name;
55 }
56
57 /**
58 * Returns the array of values associated with this request parameter.
59 *
60 * @return the parameter values array, may be null or empty
61 */
62 public String[] getValues() {
63 return values;
64 }
65
66 /**
67 * Returns a string representation of this RequestParameter.
68 * The format includes the parameter name and its values in array format.
69 *
70 * @return a string representation of this object in the format "[name, [value1, value2, ...]]"
71 */
72 @Override
73 public String toString() {
74 return "[" + name + ", " + Arrays.toString(values) + "]";
75 }
76 }