HugeGraph-726: add toList(array) method into class CollectionUtil

Change-Id: Ia8a06f002e66f11935986284f587563ebc0c2257
This commit is contained in:
Zhangmei Li 2017-08-25 11:12:42 +08:00 committed by liningrui
parent 281aab85f2
commit 4d6c421358
5 changed files with 21 additions and 12 deletions

View File

@ -6,7 +6,7 @@
<groupId>com.baidu.hugegraph</groupId>
<artifactId>hugegraph-common</artifactId>
<version>1.3.0-SNAPSHOT</version>
<version>1.3.1-SNAPSHOT</version>
<distributionManagement>
<snapshotRepository>
@ -154,7 +154,7 @@
</manifest>
<manifestEntries>
<Implementation-Version>
1.3.0.0
1.3.1.0
</Implementation-Version>
</manifestEntries>
</archive>

View File

@ -34,7 +34,7 @@ public final class CheckSocket {
private static final int E_USAGE = 1;
private static final int E_FAILED = 2;
private static final String MSG_USAGE =
"Usage: " + CheckSocket.class.getSimpleName() + " hostname port";
"Usage: " + CheckSocket.class.getSimpleName() + " hostname port";
public static void main(String args[]) {
if (args.length != 2) {

View File

@ -19,15 +19,30 @@
package com.baidu.hugegraph.util;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Created by liningrui on 2017/3/30.
*/
public final class CollectionUtil {
@SuppressWarnings({ "unchecked", "rawtypes" })
public static boolean containsAll(Collection a, Collection b) {
return a.containsAll(b);
}
@SuppressWarnings("unchecked")
public static <T> List<T> toList(Object array) {
E.checkNotNull(array, "array");
E.checkArgument(array.getClass().isArray(),
"The parameter of toList() must be an array: '%s'",
array.getClass().getSimpleName());
int length = Array.getLength(array);
List<T> list = new ArrayList<>(length);
for (int i = 0; i < length; i++) {
list.add((T) Array.get(array, i));
}
return list;
}
}

View File

@ -25,9 +25,6 @@ import javax.annotation.Nullable;
import com.google.common.base.Preconditions;
/**
* Created by liningrui on 2017/5/26.
*/
public final class E {
public static void checkNotNull(Object object, String elem) {

View File

@ -23,9 +23,6 @@ import java.nio.charset.Charset;
import com.google.common.hash.Hashing;
/**
* Created by jishilei on 2017/3/26.
*/
public final class HashUtil {
public static byte[] hash(byte[] bytes) {