Columns.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * Copyright (c) 2011-2014, hubin (jobob@qq.com).
  3. * <p>
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. * <p>
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. * <p>
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.baomidou.mybatisplus.entity;
  17. import java.io.Serializable;
  18. import java.util.ArrayList;
  19. import java.util.List;
  20. /**
  21. * <p>
  22. * 查询字段
  23. * </p>
  24. *
  25. * @author bliver
  26. * @Date 2017-07-28
  27. */
  28. public class Columns implements Serializable {
  29. private static final long serialVersionUID = 1L;
  30. private Columns() {
  31. }
  32. /**
  33. * 获取实例
  34. */
  35. public static Columns create() {
  36. return new Columns();
  37. }
  38. public Columns column(String column) {
  39. Column oneColumn = Column.create().column(column);
  40. this.columns.add(oneColumn);
  41. return this;
  42. }
  43. public Columns column(String column, String as) {
  44. Column oneColumn = Column.create().column(column).as(as);
  45. this.columns.add(oneColumn);
  46. return this;
  47. }
  48. public Columns column(String column, String as, boolean escape) {
  49. Column oneColumn = Column.create().column(column).as(as);
  50. oneColumn.setEscape(escape);
  51. this.columns.add(oneColumn);
  52. return this;
  53. }
  54. //字段
  55. private List<Column> columns = new ArrayList<>();
  56. public Column[] getColumns() {
  57. Column[] columnArray = new Column[columns.size()];
  58. return columns.toArray(columnArray);
  59. }
  60. }