Skip to content

Commit

Permalink
Use custom Objects class for clients that use Java <1.7 (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
lognaturel authored and ggalmazor committed Jul 10, 2019
1 parent 196cd18 commit 0a847a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/javarosa/core/model/FormIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

package org.javarosa.core.model;

import org.javarosa.core.model.instance.TreeReference;
import org.javarosa.core.util.Objects;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.javarosa.core.model.instance.TreeReference;

/**
* {@code FormIndex} is an immutable index which is structured to provide quick access to a specific node in a
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/javarosa/core/util/Objects.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,25 @@

package org.javarosa.core.util;

import java.util.Arrays;

/**
* TODO: replace with java.util.Objects once all clients use Java 1.7+ (for Android, that means a minSDK of 19+).
*/
public class Objects {
/**
* Null-safe equivalent of {@code a.equals(b)}.
*/
public static boolean equals(Object a, Object b) {
return (a == null) ? (b == null) : a.equals(b);
}

/**
* Convenience wrapper for {@link Arrays#hashCode}, adding varargs.
* This can be used to compute a hash code for an object's fields as follows:
* {@code Objects.hash(a, b, c)}.
*/
public static int hash(Object... values) {
return Arrays.hashCode(values);
}
}

0 comments on commit 0a847a6

Please sign in to comment.