View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.shardingsphere.sql.parser.sql.common.statement.dml;
19  
20  import lombok.Getter;
21  import lombok.Setter;
22  import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.combine.CombineSegment;
23  import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.item.ProjectionsSegment;
24  import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.GroupBySegment;
25  import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.order.OrderBySegment;
26  import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.HavingSegment;
27  import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.predicate.WhereSegment;
28  import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.table.TableSegment;
29  import org.apache.shardingsphere.sql.parser.sql.common.statement.AbstractSQLStatement;
30  
31  import java.util.Optional;
32  
33  /**
34   * Select statement.
35   */
36  @Getter
37  @Setter
38  public abstract class SelectStatement extends AbstractSQLStatement implements DMLStatement {
39      
40      private ProjectionsSegment projections;
41      
42      private TableSegment from;
43      
44      private WhereSegment where;
45      
46      private GroupBySegment groupBy;
47      
48      private HavingSegment having;
49      
50      private OrderBySegment orderBy;
51      
52      private CombineSegment combine;
53      
54      /**
55       * Get from.
56       *
57       * @return from table segment
58       */
59      public Optional<TableSegment> getFrom() {
60          return Optional.ofNullable(from);
61      }
62      
63      /**
64       * Get where.
65       *
66       * @return where segment
67       */
68      public Optional<WhereSegment> getWhere() {
69          return Optional.ofNullable(where);
70      }
71      
72      /**
73       * Get group by segment.
74       *
75       * @return group by segment
76       */
77      public Optional<GroupBySegment> getGroupBy() {
78          return Optional.ofNullable(groupBy);
79      }
80      
81      /**
82       * Get having segment.
83       *
84       * @return having segment
85       */
86      public Optional<HavingSegment> getHaving() {
87          return Optional.ofNullable(having);
88      }
89      
90      /**
91       * Get order by segment.
92       *
93       * @return order by segment
94       */
95      public Optional<OrderBySegment> getOrderBy() {
96          return Optional.ofNullable(orderBy);
97      }
98      
99      /**
100      * Get combine segment.
101      *
102      * @return combine segment
103      */
104     public Optional<CombineSegment> getCombine() {
105         return Optional.ofNullable(combine);
106     }
107 }