1 /*
2  * Copyright 2015-2018 HuntLabs.cn
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, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 module hunt.sql.dialect.mysql.ast.statement.MySqlCreateUserStatement;
17 
18 
19 import hunt.collection;
20 import hunt.sql.ast.SQLObject;
21 
22 import hunt.sql.ast.SQLExpr;
23 import hunt.sql.ast.statement.SQLCreateStatement;
24 import hunt.sql.dialect.mysql.ast.MySqlObjectImpl;
25 import hunt.sql.dialect.mysql.visitor.MySqlASTVisitor;
26 import hunt.sql.dialect.mysql.ast.statement.MySqlStatementImpl;
27 
28 public class MySqlCreateUserStatement : MySqlStatementImpl , SQLCreateStatement {
29 
30     alias accept0 = MySqlStatementImpl.accept0;
31 
32     private List!(UserSpecification) users;
33 
34     this(){
35         users = new ArrayList!(UserSpecification)(2);
36     }
37 
38     public List!(UserSpecification) getUsers() {
39         return users;
40     }
41 
42     public void addUser(UserSpecification user) {
43         if (user !is null) {
44             user.setParent(this);
45         }
46         this.users.add(user);
47     }
48 
49     override
50     public void accept0(MySqlASTVisitor visitor) {
51         if (visitor.visit(this)) {
52             acceptChild!(MySqlCreateUserStatement.UserSpecification)(visitor, users);
53         }
54         visitor.endVisit(this);
55     }
56 
57     public static class UserSpecification : MySqlObjectImpl {
58 
59         alias accept0 = MySqlObjectImpl.accept0;
60 
61         private SQLExpr user;
62         private bool passwordHash = false;
63         private SQLExpr password;
64         private SQLExpr authPlugin;
65 
66         public SQLExpr getUser() {
67             return user;
68         }
69 
70         public void setUser(SQLExpr user) {
71             this.user = user;
72         }
73 
74         public bool isPasswordHash() {
75             return passwordHash;
76         }
77 
78         public void setPasswordHash(bool passwordHash) {
79             this.passwordHash = passwordHash;
80         }
81 
82         public SQLExpr getPassword() {
83             return password;
84         }
85 
86         public void setPassword(SQLExpr password) {
87             this.password = password;
88         }
89 
90         public SQLExpr getAuthPlugin() {
91             return authPlugin;
92         }
93 
94         public void setAuthPlugin(SQLExpr authPlugin) {
95             this.authPlugin = authPlugin;
96         }
97 
98         override
99         public void accept0(MySqlASTVisitor visitor) {
100             if (visitor.visit(this)) {
101                 acceptChild(visitor, user);
102                 acceptChild(visitor, password);
103                 acceptChild(visitor, authPlugin);
104             }
105             visitor.endVisit(this);
106         }
107 
108     }
109 }