|
19 | 19 | * <http://www.gnu.org/licenses/lgpl-2.1.html>. |
20 | 20 | * #L% |
21 | 21 | */ |
22 | | -/* |
23 | | - * Copyright (C) 2015 JSQLParser. |
24 | | - * |
25 | | - * This library is free software; you can redistribute it and/or |
26 | | - * modify it under the terms of the GNU Lesser General Public |
27 | | - * License as published by the Free Software Foundation; either |
28 | | - * version 2.1 of the License, or (at your option) any later version. |
29 | | - * |
30 | | - * This library is distributed in the hope that it will be useful, |
31 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
32 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
33 | | - * Lesser General Public License for more details. |
34 | | - * |
35 | | - * You should have received a copy of the GNU Lesser General Public |
36 | | - * License along with this library; if not, write to the Free Software |
37 | | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
38 | | - * MA 02110-1301 USA |
39 | | - */ |
40 | 22 | package net.sf.jsqlparser.statement.merge; |
41 | 23 |
|
| 24 | +import java.util.List; |
| 25 | +import net.sf.jsqlparser.expression.Expression; |
| 26 | +import net.sf.jsqlparser.schema.Column; |
| 27 | + |
42 | 28 | /** |
43 | 29 | * |
44 | 30 | * @author toben |
45 | 31 | */ |
46 | 32 | public class MergeUpdate { |
47 | | - |
| 33 | + |
| 34 | + private List<Column> columns = null; |
| 35 | + private List<Expression> values = null; |
| 36 | + |
| 37 | + public List<Column> getColumns() { |
| 38 | + return columns; |
| 39 | + } |
| 40 | + |
| 41 | + public void setColumns(List<Column> columns) { |
| 42 | + this.columns = columns; |
| 43 | + } |
| 44 | + |
| 45 | + public List<Expression> getValues() { |
| 46 | + return values; |
| 47 | + } |
| 48 | + |
| 49 | + public void setValues(List<Expression> values) { |
| 50 | + this.values = values; |
| 51 | + } |
| 52 | + |
| 53 | + private Expression whereCondition; |
| 54 | + |
| 55 | + public Expression getWhereCondition() { |
| 56 | + return whereCondition; |
| 57 | + } |
| 58 | + |
| 59 | + public void setWhereCondition(Expression whereCondition) { |
| 60 | + this.whereCondition = whereCondition; |
| 61 | + } |
| 62 | + |
| 63 | + private Expression deleteWhereCondition; |
| 64 | + |
| 65 | + public Expression getDeleteWhereCondition() { |
| 66 | + return deleteWhereCondition; |
| 67 | + } |
| 68 | + |
| 69 | + public void setDeleteWhereCondition(Expression deleteWhereCondition) { |
| 70 | + this.deleteWhereCondition = deleteWhereCondition; |
| 71 | + } |
| 72 | + |
| 73 | + @Override |
| 74 | + public String toString() { |
| 75 | + StringBuilder b = new StringBuilder(); |
| 76 | + b.append(" WHEN MATCHED THEN UPDATE SET "); |
| 77 | + for (int i = 0; i < columns.size(); i++) { |
| 78 | + b.append(columns.get(i).toString()).append(" = ").append(values.get(i).toString()); |
| 79 | + } |
| 80 | + if (whereCondition != null) { |
| 81 | + b.append(" WHERE ").append(whereCondition.toString()); |
| 82 | + } |
| 83 | + if (deleteWhereCondition != null) { |
| 84 | + b.append(" DELETE WHERE ").append(deleteWhereCondition.toString()); |
| 85 | + } |
| 86 | + return b.toString(); |
| 87 | + } |
48 | 88 | } |
0 commit comments