1 /*
2 * Copyright 2016-2025 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.mybatis.dynamic.sql.util;
17
18 /**
19 * Visitor for all column mappings. Various column mappings are used by insert and update
20 * statements. Only the null and constant mappings are supported by all statements. Other mappings
21 * may or may not be supported. For example, it makes no sense to map a column to another column in
22 * an insert - so the ColumnToColumnMapping is only supported on update statements.
23 *
24 * <p>Rather than implement this interface directly, we recommend extending one of the derived
25 * classes. The derived classes encapsulate the rules about which mappings are applicable to the
26 * different types of statements.
27 *
28 * @author Jeff Butler
29 *
30 * @param <R>
31 * The type of object created by the visitor
32 */
33 public interface ColumnMappingVisitor<R> {
34 R visit(NullMapping mapping);
35
36 R visit(ConstantMapping mapping);
37
38 R visit(StringConstantMapping mapping);
39
40 <T> R visit(ValueMapping<T> mapping);
41
42 <T> R visit(ValueOrNullMapping<T> mapping);
43
44 <T> R visit(ValueWhenPresentMapping<T> mapping);
45
46 R visit(SelectMapping mapping);
47
48 R visit(PropertyMapping mapping);
49
50 R visit(PropertyWhenPresentMapping mapping);
51
52 R visit(ColumnToColumnMapping mapping);
53
54 R visit(RowMapping mapping);
55 }