HugeGraph-978: add prefixWith() for bytes

Change-Id: I17a493ef0097f9208f4cfa3aad8bbd159283f4bb
This commit is contained in:
Zhangmei Li 2017-12-11 17:35:51 +08:00 committed by liningrui
parent b01f3a35df
commit 3d3da162de
2 changed files with 39 additions and 1 deletions

View File

@ -6,7 +6,7 @@
<groupId>com.baidu.hugegraph</groupId>
<artifactId>hugegraph-common</artifactId>
<version>1.3.5-SNAPSHOT</version>
<version>1.3.6-SNAPSHOT</version>
<distributionManagement>
<snapshotRepository>

View File

@ -0,0 +1,38 @@
/*
* Copyright 2017 HugeGraph Authors
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with this
* work for additional information regarding copyright ownership. The ASF
* licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.baidu.hugegraph.util;
/**
* TODO: extends com.google.common.primitives.Bytes
*/
public final class Bytes {
public static boolean prefixWith(byte[] bytes, byte[] prefix) {
if (bytes.length < prefix.length) {
return false;
}
for (int i = 0; i < prefix.length; i++) {
if (bytes[i] != prefix[i]) {
return false;
}
}
return true;
}
}