1 /*
2  * Copyright 2014-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.spel;
17
18 import org.springframework.expression.EvaluationContext;
19 import org.springframework.expression.spel.support.StandardEvaluationContext;
20
21 /**
22  * Provides a way to access a centrally defined potentially shared {@link StandardEvaluationContext}.
23  *
24  * @author Thomas Darimont
25  * @author Oliver Gierke
26  * @author Christoph Strobl
27  * @since 2.1
28  */

29 public interface EvaluationContextProvider {
30
31     /**
32      * A simple default {@link EvaluationContextProvider} returning a {@link StandardEvaluationContext} with the given
33      * root object.
34      */

35     static EvaluationContextProvider DEFAULT = rootObject -> rootObject == null //
36             ? new StandardEvaluationContext() //
37             : new StandardEvaluationContext(rootObject);
38
39     /**
40      * Returns an {@link EvaluationContext} built using the given parameter values.
41      *
42      * @param rootObject the root object to set in the {@link EvaluationContext}.
43      * @return
44      */

45     EvaluationContext getEvaluationContext(Object rootObject);
46 }
47