-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsertQueryField.java
More file actions
executable file
·116 lines (103 loc) · 2.41 KB
/
InsertQueryField.java
File metadata and controls
executable file
·116 lines (103 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package devinfalgoust.sqlquerygenerator.insert;
import java.util.ArrayList;
import java.util.List;
/**
* The InsertQueryField Class houses the information for a given field
* within a given query. Each field has a name, a type, and a list
* of choices (that may sometimes be empty)
*
* @author Devin Falgoust
*/
public class InsertQueryField {
private String name;
private InsertQueryFieldType type;
private List<String> options;
/**
* Constructor initiating the name, type, and any options
*
* @param queryName - name of the query
* @param type - type of query
* @param options - options to choose text from
*/
public InsertQueryField(String queryName, InsertQueryFieldType type, String... options) {
name = queryName;
this.type = type;
this.options = new ArrayList<String>();
for (String s : options) {
this.options.add(s);
}
}
/**
* Returns True if the type is ID, and false otherwise
*
* @return
*/
public Boolean isID() {
return type.equals(InsertQueryFieldType.ID);
}
/**
* Returns True if the type is EMAIL, and false otherwise
*
* @return
*/
public Boolean isEmail() {
return type.equals(InsertQueryFieldType.EMAIL);
}
/**
* Returns True if the type is NAME, and false otherwise
*
* @return
*/
public Boolean isName() {
return type.equals(InsertQueryFieldType.NAME);
}
/**
* Returns True if
* 1) the type is TEXT
* 2) there are no options in the list
* Returns false otherwise
*
* @return
*/
public Boolean isRandomText() {
Boolean random = options.size() == 1 && "".equals(getOption(0));
return type.equals(InsertQueryFieldType.TEXT) && random;
}
/**
* Returns True if
* 1) the type is TEXT
* 2) there is at least one option in the list
* Returns false otherwise
*
* @return
*/
public Boolean isTextFromChoices() {
Boolean random = options.size() == 1 && "".equals(getOption(0));
return type.equals(InsertQueryFieldType.TEXT) && !random;
}
/**
* Getter for name
*
* @return
*/
public String getName() {
return name;
}
/**
* Gets the option at the specified index
*
* @param index
* @return
*/
public String getOption(int index) {
return options.get(index);
}
/**
* Returns the list of options
*
* @return
*/
public List<String> getOptions() {
return options;
}
}