1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.healthmarketscience.jackcess.util;
18
19 import java.util.Iterator;
20 import java.util.stream.Stream;
21 import java.util.stream.StreamSupport;
22
23 import com.healthmarketscience.jackcess.Database;
24 import com.healthmarketscience.jackcess.Table;
25 import com.healthmarketscience.jackcess.impl.DatabaseImpl;
26
27
28
29
30
31
32
33
34
35 public class TableIterableBuilder implements Iterable<Table>
36 {
37 private final Database _db;
38 private boolean _includeNormalTables = true;
39 private boolean _includeSystemTables;
40 private boolean _includeLinkedTables = true;
41
42 public TableIterableBuilder(Database db) {
43 _db = db;
44 }
45
46 public boolean isIncludeNormalTables() {
47 return _includeNormalTables;
48 }
49
50 public boolean isIncludeSystemTables() {
51 return _includeSystemTables;
52 }
53
54 public boolean isIncludeLinkedTables() {
55 return _includeLinkedTables;
56 }
57
58 public TableIterableBuilder setIncludeNormalTables(boolean includeNormalTables) {
59 _includeNormalTables = includeNormalTables;
60 return this;
61 }
62
63 public TableIterableBuilder setIncludeSystemTables(boolean includeSystemTables) {
64 _includeSystemTables = includeSystemTables;
65 return this;
66 }
67
68 public TableIterableBuilder setIncludeLinkedTables(boolean includeLinkedTables) {
69 _includeLinkedTables = includeLinkedTables;
70 return this;
71 }
72
73
74
75
76
77 public TableIterableBuilder withLocalUserTablesOnly() {
78 setIncludeNormalTables(true);
79 setIncludeSystemTables(false);
80 return setIncludeLinkedTables(false);
81 }
82
83
84
85
86 public TableIterableBuilder withSystemTablesOnly() {
87 setIncludeNormalTables(false);
88 setIncludeSystemTables(true);
89 return setIncludeLinkedTables(false);
90 }
91
92 @Override
93 public Iterator<Table> iterator() {
94 return ((DatabaseImpl)_db).iterator(this);
95 }
96
97
98
99
100 public Stream<Table> stream() {
101 return StreamSupport.stream(spliterator(), false);
102 }
103 }