1 /*
2 * Copyright 2017-2020 the original author or authors.
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 * https://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, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.springframework.data.jpa.repository.query;
17
18 import org.springframework.data.jpa.repository.query.JpaParameters.JpaParameter;
19 import org.springframework.data.repository.query.Parameter;
20 import org.springframework.data.repository.query.Parameters;
21 import org.springframework.data.repository.query.ParametersParameterAccessor;
22
23 /**
24 * {@link org.springframework.data.repository.query.ParameterAccessor} based on an {@link Parameters} instance. It also
25 * offers access to all the values, not just the bindable ones based on a {@link JpaParameter} instance.
26 *
27 * @author Jens Schauder
28 * @author Mark Paluch
29 */
30 public class JpaParametersParameterAccessor extends ParametersParameterAccessor {
31
32 /**
33 * Creates a new {@link ParametersParameterAccessor}.
34 *
35 * @param parameters must not be {@literal null}.
36 * @param values must not be {@literal null}.
37 */
38 JpaParametersParameterAccessor(Parameters<?, ?> parameters, Object[] values) {
39 super(parameters, values);
40 }
41
42 public <T> T getValue(Parameter parameter) {
43 return super.getValue(parameter.getIndex());
44 }
45
46 @Override
47 public Object[] getValues() {
48 return super.getValues();
49 }
50 }
51