Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduced code smell #3090

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion h2/src/main/org/h2/expression/analysis/WindowFrame.java
Expand Up @@ -27,7 +27,7 @@
*/
public final class WindowFrame {

private static abstract class Itr implements Iterator<Value[]> {
private abstract static class Itr implements Iterator<Value[]> {

final ArrayList<Value[]> orderedRows;

Expand Down
2 changes: 1 addition & 1 deletion h2/src/main/org/h2/mvstore/tx/TransactionStore.java
Expand Up @@ -881,7 +881,7 @@ public MVMap<K,V> create(MVStore store, Map<String, Object> config) {
registerDataType(getKeyType());
}
if (getValueType() == null) {
setValueType((DataType<? super V>) new VersionedValueType<V,Object>(defaultDataType));
setValueType((DataType<? super V>) new VersionedValueType<>(defaultDataType));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this change cast also needs to be removed to avoid compiler warning.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry but, I have rebuilt H2 with maven and I have not seen the warning.

registerDataType(getValueType());
}

Expand Down
2 changes: 1 addition & 1 deletion h2/src/main/org/h2/mvstore/tx/VersionedValueType.java
Expand Up @@ -158,7 +158,7 @@ public static final class Factory<D> implements StatefulDataType.Factory<D> {
@Override
public DataType<?> create(ByteBuffer buff, MetaType<D> metaType, D database) {
DataType<VersionedValue<?>> valueType = (DataType<VersionedValue<?>>)metaType.read(buff);
return new VersionedValueType<VersionedValue<?>,D>(valueType);
return new VersionedValueType<>(valueType);
}
}
}
2 changes: 1 addition & 1 deletion h2/src/main/org/h2/store/fs/FileBaseDefault.java
Expand Up @@ -18,7 +18,7 @@ public abstract class FileBaseDefault extends FileBase {
private long position = 0;

@Override
public synchronized final long position() throws IOException {
public final synchronized long position() throws IOException {
return position;
}

Expand Down
3 changes: 1 addition & 2 deletions h2/src/main/org/h2/tools/Recover.java
Expand Up @@ -548,8 +548,7 @@ private void dumpMVStoreFile(PrintWriter writer, String fileName) {
writeError(writer, e);
}

// extract the metadata so we can dump the settings
ValueDataType type = new ValueDataType();
// extract the metadata so we can dump the settings
for (String mapName : mv.getMapNames()) {
if (!mapName.startsWith("table.")) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion h2/src/main/org/h2/util/geometry/GeometryUtils.java
Expand Up @@ -13,7 +13,7 @@ public final class GeometryUtils {
/**
* Converter output target.
*/
public static abstract class Target {
public abstract static class Target {

public Target() {
}
Expand Down
2 changes: 1 addition & 1 deletion h2/src/tools/org/h2/build/doc/LinkChecker.java
Expand Up @@ -166,7 +166,7 @@ private void listBadLinks() throws Exception {
for (String error : errors) {
System.out.println(error);
}
if (errors.size() > 0) {
if (!errors.isEmpty()) {
throw new Exception("Problems where found by the Link Checker");
}
}
Expand Down
4 changes: 2 additions & 2 deletions h2/src/tools/org/h2/build/doc/XMLChecker.java
Expand Up @@ -94,7 +94,7 @@ private static void checkXML(String xml, boolean html) throws Exception {
if (event == XMLParser.END_DOCUMENT) {
break;
} else if (event == XMLParser.START_ELEMENT) {
if (stack.size() == 0) {
if (stack.isEmpty()) {
if (rootElement) {
throw new Exception("Second root element at " + parser.getRemaining());
}
Expand Down Expand Up @@ -146,7 +146,7 @@ private static void checkXML(String xml, boolean html) throws Exception {
+ parser.getRemaining());
}
}
if (stack.size() != 0) {
if (!stack.isEmpty()) {
throw new Exception("Unclosed root element");
}
}
Expand Down
10 changes: 5 additions & 5 deletions h2/src/tools/org/h2/dev/fs/ArchiveTool.java
Expand Up @@ -255,7 +255,7 @@ public int read() throws IOException {
fileIn.close();
fileIn = null;
}
if (files.size() == 0) {
if (files.isEmpty()) {
// EOF
return -1;
}
Expand Down Expand Up @@ -462,7 +462,7 @@ private static void sort(Log log, InputStream in, OutputStream out,
outPos = 0;
DataOutputStream tempOut2 = new DataOutputStream(new BufferedOutputStream(
new FileOutputStream(tempFileName + ".b"), 1024 * 1024));
while (segmentStart.size() > 0) {
while (!segmentStart.isEmpty()) {
segmentStart2.add(outPos);
int s = Math.min(segmentStart.size(), blockSize);
List<Long> start = segmentStart.subList(0, s);
Expand Down Expand Up @@ -562,7 +562,7 @@ private static Iterator<Chunk> merge(final TreeSet<ChunkStream> segmentIn, final

@Override
public boolean hasNext() {
return segmentIn.size() > 0;
return !segmentIn.isEmpty();
}

@Override
Expand Down Expand Up @@ -833,7 +833,7 @@ private static void combine(Log log, InputStream in, OutputStream out,
outPos = 0;
DataOutputStream tempOut2 = new DataOutputStream(new BufferedOutputStream(
new FileOutputStream(tempFileName + ".b"), 1024 * 1024));
while (segmentStart.size() > 0) {
while (!segmentStart.isEmpty()) {
segmentStart2.add(outPos);
int s = Math.min(segmentStart.size(), blockSize);
List<Long> start = segmentStart.subList(0, s);
Expand Down Expand Up @@ -948,7 +948,7 @@ public static Chunk read(DataInputStream in, boolean readKey) {
}
idList.add(x);
}
if (idList.size() == 0) {
if (idList.isEmpty()) {
// eof
in.close();
return null;
Expand Down
2 changes: 1 addition & 1 deletion h2/src/tools/org/h2/dev/hash/IntPerfectHash.java
Expand Up @@ -236,7 +236,7 @@ private static void generate(ArrayList<Integer> list, int level, ByteStream out)
split = Math.max(2, split);
ArrayList<ArrayList<Integer>> lists = new ArrayList<>(split);
for (int i = 0; i < split; i++) {
lists.add(new ArrayList<Integer>(size / split));
lists.add(new ArrayList<>(size / split));
}
for (int x : list) {
ArrayList<Integer> l = lists.get(hash(x, level, 0, split));
Expand Down
2 changes: 1 addition & 1 deletion h2/src/tools/org/h2/dev/hash/MinimalPerfectHash.java
Expand Up @@ -410,7 +410,7 @@ static <K> void generate(ArrayList<K> list, UniversalHash<K> hash,
do {
lists = new ArrayList<>(split);
for (int i = 0; i < split; i++) {
lists.add(new ArrayList<K>(size / split));
lists.add(new ArrayList<>(size / split));
}
for (int i = 0; i < size; i++) {
K x = list.get(i);
Expand Down
2 changes: 1 addition & 1 deletion h2/src/tools/org/h2/dev/hash/PerfectHash.java
Expand Up @@ -183,7 +183,7 @@ private static void generate(Collection<Integer> set, int level,
out.write(split);
List<List<Integer>> lists = new ArrayList<>(split);
for (int i = 0; i < split; i++) {
lists.add(new ArrayList<Integer>(size / split));
lists.add(new ArrayList<>(size / split));
}
for (int x : set) {
lists.get(hash(x, level, 0, split)).add(x);
Expand Down
4 changes: 2 additions & 2 deletions h2/src/tools/org/h2/java/Expr.java
Expand Up @@ -80,7 +80,7 @@ public String asString() {
StringBuilder buff = new StringBuilder();
initMethod();
if (method.isIgnore) {
if (args.size() == 0) {
if (args.isEmpty()) {
// ignore
} else if (args.size() == 1) {
buff.append(args.get(0));
Expand Down Expand Up @@ -394,7 +394,7 @@ class NewExpr extends ExprBase {
public String asString() {
boolean refCount = type.refCount;
StringBuilder buff = new StringBuilder();
if (arrayInitExpr.size() > 0) {
if (!arrayInitExpr.isEmpty()) {
if (refCount) {
if (classObj.isPrimitive) {
buff.append("ptr< array< " + classObj + " > >");
Expand Down