Skip to content

Commit b63ce07

Browse files
committed
replaced notNull, usability improvements.
1 parent 3a9f40f commit b63ce07

50 files changed

Lines changed: 179 additions & 214 deletions

File tree

Some content is hidden

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

src/main/java/com/ss/editor/file/converter/FileConverterDescription.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package com.ss.editor.file.converter;
22

3+
import static com.ss.rlib.util.ObjectUtils.notNull;
34
import com.ss.editor.annotation.FXThread;
4-
5+
import com.ss.rlib.util.array.Array;
56
import org.jetbrains.annotations.NotNull;
67

7-
import java.util.Objects;
88
import java.util.function.Supplier;
99

10-
import com.ss.rlib.util.array.Array;
11-
1210
/**
1311
* The description of a file converter.
1412
*
@@ -39,7 +37,7 @@ public class FileConverterDescription {
3937
@NotNull
4038
@FXThread
4139
public Array<String> getExtensions() {
42-
return Objects.requireNonNull(extensions);
40+
return notNull(extensions);
4341
}
4442

4543
/**
@@ -60,7 +58,7 @@ public void setExtensions(@NotNull final Array<String> extensions) {
6058
@NotNull
6159
@FXThread
6260
public Supplier<FileConverter> getConstructor() {
63-
return Objects.requireNonNull(constructor);
61+
return notNull(constructor);
6462
}
6563

6664
/**

src/main/java/com/ss/editor/manager/WorkspaceManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.ss.editor.manager;
22

3-
import static java.util.Objects.requireNonNull;
3+
import static com.ss.rlib.util.ObjectUtils.notNull;
44
import static com.ss.rlib.util.Utils.get;
55
import com.ss.editor.annotation.FromAnyThread;
66
import com.ss.editor.config.EditorConfig;
@@ -111,7 +111,7 @@ private synchronized Workspace getWorkspace(@NotNull final Path assetFolder) {
111111
Workspace workspace;
112112

113113
try {
114-
workspace = EditorUtil.deserialize(requireNonNull(get(workspaceFile, Files::readAllBytes)));
114+
workspace = EditorUtil.deserialize(notNull(get(workspaceFile, Files::readAllBytes)));
115115
} catch (final RuntimeException e) {
116116
workspace = new Workspace();
117117
}

src/main/java/com/ss/editor/model/undo/editor/ModelChangeConsumer.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.ss.editor.model.undo.editor;
22

3-
import com.jme3.scene.Node;
43
import com.jme3.scene.Spatial;
54
import com.ss.editor.annotation.FXThread;
65
import com.ss.editor.annotation.JMEThread;
@@ -85,22 +84,15 @@ default void notifyFXChangeProperty(@NotNull Object object, @NotNull String prop
8584
/**
8685
* Notify about replaced child from FX thread.
8786
*
88-
* @param parent the parent
89-
* @param oldChild the old child
90-
* @param newChild the new child
87+
* @param parent the parent.
88+
* @param oldChild the old child.
89+
* @param newChild the new child.
90+
* @param needExpand true of need to expand new node.
91+
* @param needDeepExpand true of need to expand new node deeply.
9192
*/
9293
@FXThread
93-
void notifyFXReplaced(@NotNull Node parent, @NotNull Spatial oldChild, @NotNull Spatial newChild);
94-
95-
/**
96-
* Notify about replaced child from FX thread.
97-
*
98-
* @param parent the parent
99-
* @param oldChild the old child
100-
* @param newChild the new child
101-
*/
102-
@FXThread
103-
void notifyFXReplaced(@NotNull Object parent, @Nullable Object oldChild, @Nullable Object newChild);
94+
void notifyFXReplaced(@NotNull Object parent, @Nullable Object oldChild, @Nullable Object newChild,
95+
boolean needExpand, boolean needDeepExpand);
10496

10597
/**
10698
* Notify about moved child from FX thread.

src/main/java/com/ss/editor/state/editor/impl/audio/AudioViewer3DState.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.ss.editor.state.editor.impl.audio;
22

3+
import static com.ss.rlib.util.ObjectUtils.notNull;
34
import com.jme3.audio.AudioData;
45
import com.jme3.audio.AudioKey;
56
import com.jme3.audio.AudioNode;
@@ -8,12 +9,9 @@
89
import com.ss.editor.annotation.FromAnyThread;
910
import com.ss.editor.state.editor.impl.AbstractEditor3DState;
1011
import com.ss.editor.ui.component.editor.impl.AudioViewerEditor;
11-
1212
import org.jetbrains.annotations.NotNull;
1313
import org.jetbrains.annotations.Nullable;
1414

15-
import java.util.Objects;
16-
1715
/**
1816
* The implementation of an editor app state for the {@link AudioViewerEditor}.
1917
*
@@ -212,7 +210,7 @@ private void setAudioNode(@Nullable final AudioNode audioNode) {
212210
*/
213211
@NotNull
214212
private AudioData getAudioData() {
215-
return Objects.requireNonNull(audioData);
213+
return notNull(audioData);
216214
}
217215

218216
/**
@@ -227,7 +225,7 @@ private void setAudioData(@NotNull final AudioData audioData) {
227225
*/
228226
@NotNull
229227
private AudioKey getAudioKey() {
230-
return Objects.requireNonNull(audioKey);
228+
return notNull(audioKey);
231229
}
232230

233231
/**

src/main/java/com/ss/editor/ui/component/creator/FileCreatorDescription.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.ss.editor.ui.component.creator;
22

3-
import static java.util.Objects.requireNonNull;
3+
import static com.ss.rlib.util.ObjectUtils.notNull;
44
import javafx.scene.image.Image;
55
import org.jetbrains.annotations.NotNull;
66
import org.jetbrains.annotations.Nullable;
@@ -57,7 +57,7 @@ public void setFileDescription(@NotNull final String fileDescription) {
5757
*/
5858
@NotNull
5959
public Callable<FileCreator> getConstructor() {
60-
return requireNonNull(constructor);
60+
return notNull(constructor);
6161
}
6262

6363
/**
@@ -67,7 +67,7 @@ public Callable<FileCreator> getConstructor() {
6767
*/
6868
@NotNull
6969
public String getFileDescription() {
70-
return requireNonNull(fileDescription);
70+
return notNull(fileDescription);
7171
}
7272

7373
/**

src/main/java/com/ss/editor/ui/component/creator/impl/material/definition/MaterialDefinitionFileCreator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import static com.ss.editor.FileExtensions.JME_MATERIAL_DEFINITION;
44
import static com.ss.rlib.util.ObjectUtils.notNull;
55
import static java.lang.Character.toUpperCase;
6-
import static java.util.Objects.requireNonNull;
76
import com.jme3.material.TechniqueDef;
87
import com.jme3.renderer.Caps;
98
import com.jme3.renderer.Renderer;
@@ -135,7 +134,7 @@ protected void processOk() {
135134
final Path vertexFile = parent.resolve(filename + "." + FileExtensions.GLSL_VERTEX);
136135

137136
final EditorConfig editorConfig = EditorConfig.getInstance();
138-
final Path assetFolder = requireNonNull(editorConfig.getCurrentAsset());
137+
final Path assetFolder = notNull(editorConfig.getCurrentAsset());
139138

140139
final Path pathToFragment = assetFolder.relativize(fragmentFile);
141140
final Path pathToVertex = assetFolder.relativize(vertexFile);

src/main/java/com/ss/editor/ui/component/editing/terrain/control/LevelTerrainToolControl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.ss.editor.ui.component.editing.terrain.control;
22

33
import static com.ss.editor.util.EditingUtils.*;
4-
import static java.util.Objects.requireNonNull;
4+
import static com.ss.rlib.util.ObjectUtils.notNull;
55
import com.jme3.math.ColorRGBA;
66
import com.jme3.math.Vector2f;
77
import com.jme3.math.Vector3f;
@@ -62,7 +62,7 @@ public LevelTerrainToolControl(@NotNull final TerrainEditingComponent component)
6262
protected void onAttached(@NotNull final Node node) {
6363
super.onAttached(node);
6464

65-
final Spatial editedModel = requireNonNull(getEditedModel());
65+
final Spatial editedModel = notNull(getEditedModel());
6666
final Geometry levelMarker = getLevelMarker();
6767

6868
final Node markersNode = component.getMarkersNode();
@@ -113,7 +113,7 @@ public void startEditing(@NotNull final EditingInput editingInput, @NotNull fina
113113
@Override
114114
public void updateEditing(@NotNull final Vector3f contactPoint) {
115115

116-
final EditingInput editingInput = requireNonNull(getCurrentInput());
116+
final EditingInput editingInput = notNull(getCurrentInput());
117117

118118
switch (editingInput) {
119119
case MOUSE_PRIMARY: {
@@ -131,7 +131,7 @@ public void updateEditing(@NotNull final Vector3f contactPoint) {
131131
public void finishEditing(@NotNull final Vector3f contactPoint) {
132132
super.finishEditing(contactPoint);
133133

134-
final EditingInput editingInput = requireNonNull(getCurrentInput());
134+
final EditingInput editingInput = notNull(getCurrentInput());
135135

136136
switch (editingInput) {
137137
case MOUSE_PRIMARY: {
@@ -154,7 +154,7 @@ public void finishEditing(@NotNull final Vector3f contactPoint) {
154154
private void modifyHeight(@NotNull final Vector3f contactPoint) {
155155

156156
final LocalObjects local = LocalObjects.get();
157-
final Node terrainNode = (Node) requireNonNull(getEditedModel());
157+
final Node terrainNode = (Node) notNull(getEditedModel());
158158
final Geometry levelMarker = getLevelMarker();
159159

160160
final Vector3f markerTranslation = levelMarker.getLocalTranslation();

src/main/java/com/ss/editor/ui/component/editing/terrain/control/PaintTerrainToolControl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.ss.editor.ui.component.editing.terrain.control;
22

3-
import static java.util.Objects.requireNonNull;
3+
import static com.ss.rlib.util.ObjectUtils.notNull;
44
import com.jme3.math.ColorRGBA;
55
import com.jme3.math.Vector2f;
66
import com.jme3.math.Vector3f;
@@ -169,7 +169,7 @@ public void startEditing(@NotNull final EditingInput editingInput, @NotNull fina
169169
@Override
170170
public void updateEditing(@NotNull final Vector3f contactPoint) {
171171

172-
final EditingInput currentInput = requireNonNull(getCurrentInput());
172+
final EditingInput currentInput = notNull(getCurrentInput());
173173

174174
switch (currentInput) {
175175
case MOUSE_PRIMARY:
@@ -183,7 +183,7 @@ public void updateEditing(@NotNull final Vector3f contactPoint) {
183183
@Override
184184
public void finishEditing(@NotNull final Vector3f contactPoint) {
185185

186-
final EditingInput currentInput = requireNonNull(getCurrentInput());
186+
final EditingInput currentInput = notNull(getCurrentInput());
187187

188188
switch (currentInput) {
189189
case MOUSE_PRIMARY:
@@ -213,7 +213,7 @@ private void startChange() {
213213
final Array<ColorPoint> colorPoints = getColorPoints();
214214
colorPoints.clear();
215215

216-
final Texture alphaTexture = requireNonNull(getAlphaTexture());
216+
final Texture alphaTexture = notNull(getAlphaTexture());
217217
final Image image = alphaTexture.getImage();
218218
final ByteBuffer data = image.getData(0);
219219

@@ -259,7 +259,7 @@ protected void change(final int index, @NotNull final ColorRGBA color) {
259259
*/
260260
@NotNull
261261
private ByteBuffer getPrevBuffer() {
262-
return requireNonNull(prevBuffer);
262+
return notNull(prevBuffer);
263263
}
264264

265265
/**
@@ -268,7 +268,7 @@ private ByteBuffer getPrevBuffer() {
268268
private void commitChanges() {
269269

270270
final ByteBuffer prevBuffer = getPrevBuffer();
271-
final Texture alphaTexture = requireNonNull(getAlphaTexture());
271+
final Texture alphaTexture = notNull(getAlphaTexture());
272272
final Image image = alphaTexture.getImage();
273273

274274
final Array<ColorPoint> colorPoints = getColorPoints();
@@ -413,7 +413,7 @@ private void paintTexture(@NotNull final EditingInput editingInput, @NotNull fin
413413
if (alphaTexture == null) return;
414414

415415
final LocalObjects local = LocalObjects.get();
416-
final Spatial terrainNode = requireNonNull(getEditedModel());
416+
final Spatial terrainNode = notNull(getEditedModel());
417417
final Terrain terrain = (Terrain) terrainNode;
418418
final Image image = alphaTexture.getImage();
419419

src/main/java/com/ss/editor/ui/component/editing/terrain/control/RaiseLowerTerrainToolControl.java

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

33
import static com.ss.editor.util.EditingUtils.calculateHeight;
44
import static com.ss.editor.util.EditingUtils.isContains;
5-
import static java.util.Objects.requireNonNull;
5+
import static com.ss.rlib.util.ObjectUtils.notNull;
66
import com.jme3.math.ColorRGBA;
77
import com.jme3.math.Vector2f;
88
import com.jme3.math.Vector3f;
@@ -55,7 +55,7 @@ public void startEditing(@NotNull final EditingInput editingInput, @NotNull fina
5555
@Override
5656
public void updateEditing(@NotNull final Vector3f contactPoint) {
5757

58-
final EditingInput editingInput = requireNonNull(getCurrentInput());
58+
final EditingInput editingInput = notNull(getCurrentInput());
5959

6060
switch (editingInput) {
6161
case MOUSE_PRIMARY:
@@ -69,7 +69,7 @@ public void updateEditing(@NotNull final Vector3f contactPoint) {
6969
public void finishEditing(@NotNull final Vector3f contactPoint) {
7070
super.finishEditing(contactPoint);
7171

72-
final EditingInput editingInput = requireNonNull(getCurrentInput());
72+
final EditingInput editingInput = notNull(getCurrentInput());
7373

7474
switch (editingInput) {
7575
case MOUSE_PRIMARY:
@@ -89,7 +89,7 @@ public void finishEditing(@NotNull final Vector3f contactPoint) {
8989
private void modifyHeight(@NotNull final EditingInput editingInput, @NotNull final Vector3f contactPoint) {
9090

9191
final LocalObjects local = LocalObjects.get();
92-
final Node terrainNode = (Node) requireNonNull(getEditedModel());
92+
final Node terrainNode = (Node) notNull(getEditedModel());
9393

9494
final Vector3f worldTranslation = terrainNode.getWorldTranslation();
9595
final Vector3f localScale = terrainNode.getLocalScale();

src/main/java/com/ss/editor/ui/component/editing/terrain/control/RoughTerrainToolControl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.ss.editor.ui.component.editing.terrain.control;
22

33
import static com.ss.editor.util.EditingUtils.isContains;
4+
import static com.ss.rlib.util.ObjectUtils.notNull;
45
import static java.lang.Math.max;
56
import static java.lang.Math.min;
6-
import static java.util.Objects.requireNonNull;
77
import com.jme3.math.ColorRGBA;
88
import com.jme3.math.Vector2f;
99
import com.jme3.math.Vector3f;
@@ -71,7 +71,7 @@ public void startEditing(@NotNull final EditingInput editingInput, @NotNull fina
7171
@Override
7272
public void updateEditing(@NotNull final Vector3f contactPoint) {
7373

74-
final EditingInput editingInput = requireNonNull(getCurrentInput());
74+
final EditingInput editingInput = notNull(getCurrentInput());
7575

7676
switch (editingInput) {
7777
case MOUSE_PRIMARY: {
@@ -84,7 +84,7 @@ public void updateEditing(@NotNull final Vector3f contactPoint) {
8484
public void finishEditing(@NotNull final Vector3f contactPoint) {
8585
super.finishEditing(contactPoint);
8686

87-
final EditingInput editingInput = requireNonNull(getCurrentInput());
87+
final EditingInput editingInput = notNull(getCurrentInput());
8888

8989
switch (editingInput) {
9090
case MOUSE_PRIMARY: {
@@ -102,7 +102,7 @@ public void finishEditing(@NotNull final Vector3f contactPoint) {
102102
private void modifyHeight(@NotNull final Vector3f contactPoint) {
103103

104104
final LocalObjects local = LocalObjects.get();
105-
final Node terrainNode = (Node) requireNonNull(getEditedModel());
105+
final Node terrainNode = (Node) notNull(getEditedModel());
106106

107107
final Vector3f worldTranslation = terrainNode.getWorldTranslation();
108108
final Vector3f localScale = terrainNode.getLocalScale();

0 commit comments

Comments
 (0)