Skip to content

Commit eacd750

Browse files
committed
Add static analysis tools
1 parent 1019483 commit eacd750

File tree

68 files changed

+492
-234
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+492
-234
lines changed

patternfx-core/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
<groupId>org.slf4j</groupId>
1919
<artifactId>slf4j-api</artifactId>
2020
</dependency>
21+
<dependency>
22+
<groupId>com.techsenger.annotations</groupId>
23+
<artifactId>annotations</artifactId>
24+
</dependency>
2125
<dependency>
2226
<groupId>com.techsenger.toolkit</groupId>
2327
<artifactId>toolkit-fx</artifactId>

patternfx-core/src/main/java/com/techsenger/patternfx/core/AbstractBreadthFirstIterator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package com.techsenger.patternfx.core;
1818

19-
import java.util.LinkedList;
19+
import java.util.ArrayDeque;
2020
import java.util.List;
2121
import java.util.NoSuchElementException;
2222
import java.util.Queue;
@@ -28,7 +28,7 @@
2828
*/
2929
public abstract class AbstractBreadthFirstIterator<T, S> implements TreeIterator<T> {
3030

31-
private final Queue<Pair<S, Integer>> queue = new LinkedList<>();
31+
private final Queue<Pair<S, Integer>> queue = new ArrayDeque<>(32);
3232

3333
private int currentDepth = -1;
3434

patternfx-core/src/main/java/com/techsenger/patternfx/core/AbstractDepthFirstIterator.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616

1717
package com.techsenger.patternfx.core;
1818

19+
import java.util.ArrayDeque;
20+
import java.util.Deque;
1921
import java.util.List;
2022
import java.util.NoSuchElementException;
21-
import java.util.Stack;
2223
import javafx.util.Pair;
2324

2425
/**
@@ -27,12 +28,12 @@
2728
*/
2829
public abstract class AbstractDepthFirstIterator<T, S> implements TreeIterator<T> {
2930

30-
private final Stack<Pair<S, Integer>> stack = new Stack<>();
31+
private final Deque<Pair<S, Integer>> stack = new ArrayDeque<>(32);
3132

3233
private int currentDepth = -1;
3334

3435
protected AbstractDepthFirstIterator(S root) {
35-
stack.push(new Pair<>(root, 0));
36+
stack.addFirst(new Pair<>(root, 0));
3637
}
3738

3839
@Override
@@ -45,21 +46,21 @@ public int getDepth() {
4546

4647
@Override
4748
public boolean hasNext() {
48-
return !stack.isEmpty();
49+
return !stack.isEmpty();
4950
}
5051

5152
@Override
5253
public T next() {
5354
if (!hasNext()) {
5455
throw new NoSuchElementException();
5556
}
56-
var pair = stack.pop();
57+
var pair = stack.removeFirst();
5758
S node = pair.getKey();
5859
this.currentDepth = pair.getValue();
5960
var children = getChildren(node);
6061
for (int i = children.size() - 1; i >= 0; i--) {
61-
S child = children.get(i);
62-
stack.push(new Pair<>(child, currentDepth + 1));
62+
S child = children.get(i);
63+
stack.addFirst(new Pair<>(child, currentDepth + 1));
6364
}
6465
return map(node);
6566
}

patternfx-core/src/main/java/com/techsenger/patternfx/core/AbstractDescriptor.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.techsenger.patternfx.core;
1818

19+
import com.techsenger.annotations.Nullable;
1920
import java.util.Objects;
2021
import java.util.UUID;
2122
import java.util.function.Function;
@@ -50,7 +51,7 @@ public static void setLogPrefixResolver(Function<ReadOnlyDescriptor, String> log
5051

5152
private final ReadOnlyObjectWrapper<ComponentState> state = new ReadOnlyObjectWrapper<>(ComponentState.CREATING);
5253

53-
private final ReadOnlyObjectWrapper<ComponentGroup> group = new ReadOnlyObjectWrapper<>();
54+
private final ReadOnlyObjectWrapper<ComponentGroup> group = new ReadOnlyObjectWrapper<>();
5455

5556
protected AbstractDescriptor(ComponentName name) {
5657
this(name, UUID.randomUUID());
@@ -95,19 +96,19 @@ public ComponentState getState() {
9596
}
9697

9798
@Override
98-
public ComponentGroup getGroup() {
99+
public @Nullable ComponentGroup getGroup() {
99100
return group.get();
100101
}
101102

102103
protected void setState(ComponentState state) {
103104
this.state.set(state);
104105
}
105106

106-
protected void setGroup(ComponentGroup group) {
107+
protected void setGroup(@Nullable ComponentGroup group) {
107108
this.group.set(group);
108109
}
109110

110-
protected ReadOnlyObjectWrapper<ComponentState> getStateWrapper() {
111+
protected ReadOnlyObjectWrapper<ComponentState> getStateWrapper() {
111112
return state;
112113
}
113114

patternfx-core/src/main/java/com/techsenger/patternfx/core/AbstractName.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@
1616

1717
package com.techsenger.patternfx.core;
1818

19+
import com.techsenger.annotations.Nullable;
20+
1921
/**
2022
*
2123
* @author Pavel Castornii
2224
*/
2325
public abstract class AbstractName implements Name {
2426

25-
private final String text;
27+
private final @Nullable String text;
2628

27-
public AbstractName(String text) {
29+
public AbstractName(@Nullable String text) {
2830
this.text = text;
2931
}
3032

@@ -33,12 +35,13 @@ public AbstractName(String text) {
3335
*
3436
* @return the component name text
3537
*/
36-
public String getText() {
38+
@Override
39+
public @Nullable String getText() {
3740
return text;
3841
}
3942

4043
@Override
4144
public String toString() {
42-
return this.text;
45+
return getClass().getSimpleName() + "[text=" + String.valueOf(text) + "]";
4346
}
4447
}

patternfx-core/src/main/java/com/techsenger/patternfx/core/ComponentGroupName.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.techsenger.patternfx.core;
1818

19+
import java.util.Objects;
20+
1921
/**
2022
*
2123
* @author Pavel Castornii
@@ -33,6 +35,6 @@ public ComponentGroupName(String text) {
3335
*/
3436
@Override
3537
public String getText() {
36-
return super.getText();
38+
return Objects.requireNonNull(super.getText());
3739
}
3840
}

patternfx-core/src/main/java/com/techsenger/patternfx/core/Name.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.techsenger.patternfx.core;
1818

19+
import com.techsenger.annotations.Nullable;
20+
1921
/**
2022
*
2123
* @author Pavel Castornii
@@ -27,5 +29,5 @@ public interface Name {
2729
*
2830
* @return the component name text
2931
*/
30-
String getText();
32+
@Nullable String getText();
3133
}

patternfx-core/src/main/java/com/techsenger/patternfx/core/ObservableReadOnlyDescriptor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public interface ObservableReadOnlyDescriptor extends ReadOnlyDescriptor {
2828
/**
2929
* Returns the state property of the component.
3030
*
31-
* @return
3231
*/
3332
ReadOnlyObjectProperty<ComponentState> stateProperty();
3433

patternfx-core/src/main/java/com/techsenger/patternfx/core/ReadOnlyDescriptor.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.techsenger.patternfx.core;
1818

19+
import com.techsenger.annotations.Nullable;
1920
import java.util.UUID;
2021

2122
/**
@@ -43,8 +44,6 @@ public interface ReadOnlyDescriptor {
4344

4445
/**
4546
* Returns the first 32 bits of the UUID.
46-
*
47-
* @return
4847
*/
4948
String getShortUuid();
5049

@@ -68,7 +67,6 @@ public interface ReadOnlyDescriptor {
6867

6968
/**
7069
* Returns the state of the component.
71-
* @return
7270
*/
7371
ComponentState getState();
7472

@@ -77,5 +75,5 @@ public interface ReadOnlyDescriptor {
7775
*
7876
* @return the current component group
7977
*/
80-
ComponentGroup getGroup();
78+
@Nullable ComponentGroup getGroup();
8179
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright 2024-2025 Pavel Castornii.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@NullMarked
18+
package com.techsenger.patternfx.core;
19+
20+
import com.techsenger.annotations.NullMarked;
21+

0 commit comments

Comments
 (0)