Skip to content

Commit 16ccb75

Browse files
committed
Checkstyle & Spotless
1 parent fc57aac commit 16ccb75

File tree

3 files changed

+113
-115
lines changed

3 files changed

+113
-115
lines changed

src/main/java/net/sf/jsqlparser/statement/lock/LockMode.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@
44
* Describes the LockMode of a LOCK TABLE-Statement.
55
*/
66
public enum LockMode {
7-
// These two modes are more common
8-
Share("SHARE"),
9-
Exclusive("EXCLUSIVE"),
7+
// These two modes are more common
8+
Share("SHARE"), Exclusive("EXCLUSIVE"),
109

11-
// These are Oracle specific, as far as I know
12-
RowShare("ROW SHARE"),
13-
RowExclusive("ROW EXCLUSIVE"),
14-
ShareUpdate("SHARE UPDATE"),
15-
ShareRowExclusive("SHARE ROW EXCLUSIVE");
10+
// These are Oracle specific, as far as I know
11+
RowShare("ROW SHARE"), RowExclusive("ROW EXCLUSIVE"), ShareUpdate(
12+
"SHARE UPDATE"), ShareRowExclusive("SHARE ROW EXCLUSIVE");
1613

17-
private final String value;
14+
private final String value;
1815

19-
LockMode(String value) {
20-
this.value = value;
21-
}
16+
LockMode(String value) {
17+
this.value = value;
18+
}
2219

23-
public String getValue() {
24-
return value;
25-
}
20+
public String getValue() {
21+
return value;
22+
}
2623

27-
}
24+
}

src/main/java/net/sf/jsqlparser/statement/lock/LockStatement.java

Lines changed: 97 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -12,100 +12,101 @@
1212
*/
1313
public class LockStatement implements Statement {
1414

15-
private Table table;
16-
private LockMode lockMode;
17-
private boolean noWait;
18-
private Long waitSeconds;
19-
20-
/**
21-
* Creates a new LockStatement
22-
*
23-
* @param table The table to lock
24-
* @param lockMode The lock mode
25-
*/
26-
public LockStatement(Table table, LockMode lockMode) {
27-
this.table = table;
28-
this.lockMode = lockMode;
29-
}
30-
31-
public LockStatement(Table table, LockMode lockMode, boolean noWait, Long waitSeconds) {
32-
this(table, lockMode);
33-
this.table = table;
34-
this.lockMode = lockMode;
35-
this.noWait = noWait;
36-
this.waitSeconds = waitSeconds;
37-
}
38-
39-
private void checkValidState() {
40-
if (noWait && waitSeconds != null) {
41-
throw new IllegalStateException("A LOCK statement cannot have NOWAIT and WAIT at the same time");
42-
}
43-
}
44-
45-
public Table getTable() {
46-
return table;
47-
}
48-
49-
public void setTable(Table table) {
50-
this.table = table;
51-
}
52-
53-
public LockMode getLockMode() {
54-
return lockMode;
55-
}
56-
57-
public void setLockMode(LockMode lockMode) {
58-
this.lockMode = lockMode;
59-
}
60-
61-
public boolean isNoWait() {
62-
return noWait;
63-
}
64-
65-
/**
66-
* Sets the NOWAIT-Flag. Clears a WAIT-Timeout if one was set before.
67-
*
68-
* @param noWait The new value of the NOWAIT-Flag
69-
*/
70-
public void setNoWait(boolean noWait) {
71-
this.waitSeconds = null;
72-
this.noWait = noWait;
73-
checkValidState();
74-
}
75-
76-
public boolean isWait() {
77-
return waitSeconds != null;
78-
}
79-
80-
/**
81-
* Sets the WAIT-Timeout. If this value is set, the Statement is rendered with WAIT <timeoutSeconds>
82-
*
83-
* @param waitSeconds The number of seconds for the WAIT timeout
84-
*/
85-
public void setWaitSeconds(long waitSeconds) {
86-
this.noWait = false;
87-
this.waitSeconds = waitSeconds;
88-
checkValidState();
89-
}
90-
91-
@Override
92-
public String toString() {
93-
return
94-
"LOCK TABLE "
95-
+ table.getFullyQualifiedName()
96-
+ " IN "
97-
+ lockMode.getValue()
98-
+ " MODE"
99-
+ (noWait ? " NOWAIT" : "")
100-
+ (waitSeconds != null ? " WAIT " + waitSeconds : "");
101-
}
102-
103-
@Override
104-
public <T, S> T accept(StatementVisitor<T> statementVisitor, S context) {
105-
return statementVisitor.visit(this, context);
106-
}
107-
108-
public long getWaitTimeout() {
109-
return waitSeconds;
110-
}
15+
private Table table;
16+
private LockMode lockMode;
17+
private boolean noWait;
18+
private Long waitSeconds;
19+
20+
/**
21+
* Creates a new LockStatement
22+
*
23+
* @param table The table to lock
24+
* @param lockMode The lock mode
25+
*/
26+
public LockStatement(Table table, LockMode lockMode) {
27+
this.table = table;
28+
this.lockMode = lockMode;
29+
}
30+
31+
public LockStatement(Table table, LockMode lockMode, boolean noWait, Long waitSeconds) {
32+
this(table, lockMode);
33+
this.table = table;
34+
this.lockMode = lockMode;
35+
this.noWait = noWait;
36+
this.waitSeconds = waitSeconds;
37+
}
38+
39+
private void checkValidState() {
40+
if (noWait && waitSeconds != null) {
41+
throw new IllegalStateException(
42+
"A LOCK statement cannot have NOWAIT and WAIT at the same time");
43+
}
44+
}
45+
46+
public Table getTable() {
47+
return table;
48+
}
49+
50+
public void setTable(Table table) {
51+
this.table = table;
52+
}
53+
54+
public LockMode getLockMode() {
55+
return lockMode;
56+
}
57+
58+
public void setLockMode(LockMode lockMode) {
59+
this.lockMode = lockMode;
60+
}
61+
62+
public boolean isNoWait() {
63+
return noWait;
64+
}
65+
66+
/**
67+
* Sets the NOWAIT-Flag. Clears a WAIT-Timeout if one was set before.
68+
*
69+
* @param noWait The new value of the NOWAIT-Flag
70+
*/
71+
public void setNoWait(boolean noWait) {
72+
this.waitSeconds = null;
73+
this.noWait = noWait;
74+
checkValidState();
75+
}
76+
77+
public boolean isWait() {
78+
return waitSeconds != null;
79+
}
80+
81+
/**
82+
* Sets the WAIT-Timeout. If this value is set, the Statement is rendered with WAIT
83+
* &lt;timeoutSeconds&gt;
84+
*
85+
* @param waitSeconds The number of seconds for the WAIT timeout
86+
*/
87+
public void setWaitSeconds(long waitSeconds) {
88+
this.noWait = false;
89+
this.waitSeconds = waitSeconds;
90+
checkValidState();
91+
}
92+
93+
@Override
94+
public String toString() {
95+
return "LOCK TABLE "
96+
+ table.getFullyQualifiedName()
97+
+ " IN "
98+
+ lockMode.getValue()
99+
+ " MODE"
100+
+ (noWait ? " NOWAIT" : "")
101+
+ (waitSeconds != null ? " WAIT " + waitSeconds : "");
102+
}
103+
104+
@Override
105+
public <T, S> T accept(StatementVisitor<T> statementVisitor, S context) {
106+
return statementVisitor.visit(this, context);
107+
}
108+
109+
public long getWaitTimeout() {
110+
return waitSeconds;
111+
}
111112
}

src/test/java/net/sf/jsqlparser/statement/lock/LockTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void testLockExclusiveMode() throws JSQLParserException {
3939
Statement statement = CCJSqlParserUtil.parse(sqlStr);
4040
assertInstanceOf(LockStatement.class, statement);
4141

42-
LockStatement ls = (LockStatement)statement;
42+
LockStatement ls = (LockStatement) statement;
4343
assertEquals(LockMode.Exclusive, ls.getLockMode());
4444
assertFalse(ls.isNoWait());
4545
}
@@ -50,7 +50,7 @@ void testNoWait() throws JSQLParserException {
5050
Statement statement = CCJSqlParserUtil.parse(sqlStr);
5151
assertInstanceOf(LockStatement.class, statement);
5252

53-
LockStatement ls = (LockStatement)statement;
53+
LockStatement ls = (LockStatement) statement;
5454
assertEquals(LockMode.Share, ls.getLockMode());
5555
assertTrue(ls.isNoWait());
5656
}
@@ -61,7 +61,7 @@ void testWaitTimeout() throws JSQLParserException {
6161
Statement statement = CCJSqlParserUtil.parse(sqlStr);
6262
assertInstanceOf(LockStatement.class, statement);
6363

64-
LockStatement ls = (LockStatement)statement;
64+
LockStatement ls = (LockStatement) statement;
6565
assertEquals(LockMode.Share, ls.getLockMode());
6666
assertTrue(ls.isWait());
6767
assertEquals(300, ls.getWaitTimeout());

0 commit comments

Comments
 (0)