/** * Get auth plugin data. * * @return auth plugin data */ public byte[] getAuthPluginData() { return Bytes.concat(authPluginDataPart1, authPluginDataPart2); } }
/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * @param array an array of {@code byte} values, possibly empty * @param target a primitive {@code byte} value * @return the least index {@code i} for which {@code array[i] == target}, or {@code -1} if no * such index exists. */ public static int indexOf(byte[] array, byte target) { return indexOf(array, target, 0, array.length); }
public void testAsList_subList_toArray_roundTrip() { byte[] array = {(byte) 0, (byte) 1, (byte) 2, (byte) 3}; List<Byte> list = Bytes.asList(array); assertTrue(Arrays.equals(new byte[] {(byte) 1, (byte) 2}, Bytes.toArray(list.subList(1, 3)))); assertTrue(Arrays.equals(new byte[] {}, Bytes.toArray(list.subList(2, 2)))); }
private static List<Byte> asList(Byte[] values) { byte[] temp = new byte[values.length]; for (int i = 0; i < values.length; i++) { temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize). } return Bytes.asList(temp); }
@Override public PersistedData serializeCollection(Collection<Byte> value, SerializationContext context) { return context.create(Bytes.toArray(value)); }
/** * Returns the index of the last appearance of the value {@code target} in {@code array}. * * @param array an array of {@code byte} values, possibly empty * @param target a primitive {@code byte} value * @return the greatest index {@code i} for which {@code array[i] == target}, or {@code -1} if no * such index exists. */ public static int lastIndexOf(byte[] array, byte target) { return lastIndexOf(array, target, 0, array.length); }
@Override public int hashCode() { int result = 1; for (int i = start; i < end; i++) { result = 31 * result + Bytes.hashCode(array[i]); } return result; }
public void testToArray_withNull() { List<Byte> list = Arrays.asList((byte) 0, (byte) 1, null); try { Bytes.toArray(list); fail(); } catch (NullPointerException expected) { } }
/** * Returns the index of the last appearance of the value {@code target} in {@code array}. * * @param array an array of {@code byte} values, possibly empty * @param target a primitive {@code byte} value * @return the greatest index {@code i} for which {@code array[i] == target}, or {@code -1} if no * such index exists. */ public static int lastIndexOf(byte[] array, byte target) { return lastIndexOf(array, target, 0, array.length); }
@Override public int hashCode() { int result = 1; for (int i = start; i < end; i++) { result = 31 * result + Bytes.hashCode(array[i]); } return result; }
/** * Get auth plugin data. * * @return auth plugin data */ public byte[] getAuthPluginData() { return Bytes.concat(authPluginDataPart1, authPluginDataPart2); } }
public void testToArray() { // need explicit type parameter to avoid javac warning!? List<Byte> none = Arrays.<Byte>asList(); assertTrue(Arrays.equals(EMPTY, Bytes.toArray(none))); List<Byte> one = Arrays.asList((byte) 1); assertTrue(Arrays.equals(ARRAY1, Bytes.toArray(one))); byte[] array = {(byte) 0, (byte) 1, (byte) 0x55}; List<Byte> three = Arrays.asList((byte) 0, (byte) 1, (byte) 0x55); assertTrue(Arrays.equals(array, Bytes.toArray(three))); assertTrue(Arrays.equals(array, Bytes.toArray(Bytes.asList(array)))); }
/** * Returns the index of the first appearance of the value {@code target} in {@code array}. * * @param array an array of {@code byte} values, possibly empty * @param target a primitive {@code byte} value * @return the least index {@code i} for which {@code array[i] == target}, or {@code -1} if no * such index exists. */ public static int indexOf(byte[] array, byte target) { return indexOf(array, target, 0, array.length); }
public static IterableChecker<List<Byte>, Byte> check(byte[] actualByteArray) { return check(actualByteArray == null ? null : Bytes.asList(actualByteArray)); }
public void testToArray_withConversion() { byte[] array = {(byte) 0, (byte) 1, (byte) 2}; List<Byte> bytes = Arrays.asList((byte) 0, (byte) 1, (byte) 2); List<Short> shorts = Arrays.asList((short) 0, (short) 1, (short) 2); List<Integer> ints = Arrays.asList(0, 1, 2); List<Float> floats = Arrays.asList((float) 0, (float) 1, (float) 2); List<Long> longs = Arrays.asList((long) 0, (long) 1, (long) 2); List<Double> doubles = Arrays.asList((double) 0, (double) 1, (double) 2); assertTrue(Arrays.equals(array, Bytes.toArray(bytes))); assertTrue(Arrays.equals(array, Bytes.toArray(shorts))); assertTrue(Arrays.equals(array, Bytes.toArray(ints))); assertTrue(Arrays.equals(array, Bytes.toArray(floats))); assertTrue(Arrays.equals(array, Bytes.toArray(longs))); assertTrue(Arrays.equals(array, Bytes.toArray(doubles))); }
/** * Returns the index of the last appearance of the value {@code target} in {@code array}. * * @param array an array of {@code byte} values, possibly empty * @param target a primitive {@code byte} value * @return the greatest index {@code i} for which {@code array[i] == target}, or {@code -1} if no * such index exists. */ public static int lastIndexOf(byte[] array, byte target) { return lastIndexOf(array, target, 0, array.length); }
@Override public int hashCode() { int result = 1; for (int i = start; i < end; i++) { result = 31 * result + Bytes.hashCode(array[i]); } return result; }
@Override public byte[] getCacheKey() { byte[] cacheKey = new byte[]{ExtractionCacheHelper.CACHE_TYPE_ID_CASCADE}; return Bytes.concat(cacheKey, chainedExtractionFn.getCacheKey()); }
public void testAsList_toArray_roundTrip() { byte[] array = {(byte) 0, (byte) 1, (byte) 2}; List<Byte> list = Bytes.asList(array); byte[] newArray = Bytes.toArray(list); // Make sure it returned a copy list.set(0, (byte) 4); assertTrue(Arrays.equals(new byte[] {(byte) 0, (byte) 1, (byte) 2}, newArray)); newArray[1] = (byte) 5; assertEquals((byte) 1, (byte) list.get(1)); }