Skip to content

Commit

Permalink
chore/style: typo fix and suppress warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bogovicj committed Jul 16, 2024
1 parent 78e0349 commit e547bfd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public URI uri(final String normalPath) throws URISyntaxException {
try {
final URI normalUri = URI.create(normalPath);
if (normalUri.isAbsolute()) return normalUri.normalize();
} catch (IllegalArgumentException e) {
} catch (final IllegalArgumentException e) {
return new File(normalPath).toURI().normalize();
}
return new File(normalPath).toURI().normalize();
Expand Down Expand Up @@ -445,7 +445,7 @@ protected static Path createDirectories(Path dir, final FileAttribute<?>... attr
// don't have permission to get absolute path
se = x;
}
// find a decendent that exists
// find a descendant that exists
Path parent = dir.getParent();
while (parent != null) {
try {
Expand Down Expand Up @@ -485,7 +485,7 @@ protected static Path createDirectories(Path dir, final FileAttribute<?>... attr
*
* Used by createDirectories to attempt to create a directory. A no-op if the
* directory already exists.
*
*
* @param dir directory path
* @param attrs file attributes
* @throws IOException the exception
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/janelia/saalfeldlab/n5/GsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ static <T> T readAttribute(
* @return the deserialized attribute object, or {@code null} if
* {@code attribute} cannot deserialize to {@code T}
*/
@SuppressWarnings("unchecked")
static <T> T parseAttributeElement(final JsonElement attribute, final Gson gson, final Type type) throws JsonSyntaxException, NumberFormatException, ClassCastException {

if (attribute == null)
Expand Down Expand Up @@ -266,6 +267,7 @@ static <T> T getJsonAsArray(final Gson gson, final JsonArray array, final Class<
return getJsonAsArray(gson, array, TypeToken.get(cls).getType());
}

@SuppressWarnings("unchecked")
static <T> T getJsonAsArray(final Gson gson, final JsonArray array, final Type type) {

final Class<?> clazz = (type instanceof Class<?>) ? ((Class<?>)type) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public boolean jsonCompatible(final JsonElement json) {
* to attempt to set to {@link #parentJson}
* @return the value set to {@link #parentJson}.
*/
@SuppressWarnings("unchecked")
protected JsonElement setAndCreateParentElement(final JsonElement json) {

if (json == null || !jsonCompatible(json)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public boolean isGroup() {
}
}

@SuppressWarnings("deprecation")
protected static class EmptyJson extends JsonElement {

@Override
Expand Down
44 changes: 23 additions & 21 deletions src/test/java/org/janelia/saalfeldlab/n5/AbstractN5Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,13 @@
*/
package org.janelia.saalfeldlab.n5;

import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
import org.janelia.saalfeldlab.n5.N5Exception.N5ClassCastException;
import org.janelia.saalfeldlab.n5.N5Reader.Version;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import java.net.URISyntaxException;
Expand All @@ -53,13 +48,19 @@
import java.util.concurrent.Executors;
import java.util.function.Predicate;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import org.janelia.saalfeldlab.n5.N5Exception.N5ClassCastException;
import org.janelia.saalfeldlab.n5.N5Reader.Version;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;

/**
* Abstract base class for testing N5 functionality.
Expand Down Expand Up @@ -117,10 +118,10 @@ protected final N5Writer createTempN5Writer(String location, GsonBuilder gson) {
@After
public void removeTempWriters() {
synchronized (tempWriters) {
for (N5Writer writer : tempWriters) {
for (final N5Writer writer : tempWriters) {
try {
writer.remove();
} catch (Exception e) {
} catch (final Exception e) {
}
}
tempWriters.clear();
Expand Down Expand Up @@ -1168,6 +1169,7 @@ public static class TestData<T> {
public T attributeValue;
public Class<T> attributeClass;

@SuppressWarnings("unchecked")
public TestData(final String groupPath, final String key, final T attributeValue) {

this.groupPath = groupPath;
Expand Down

0 comments on commit e547bfd

Please sign in to comment.