+ @Nonnull public final P6 ipv6PrefixForShort(@Nonnull final byte[] address, final int mask) {
+ return ipv6PrefixForShort(address, 0, mask);
+ }
+
+ @Nonnull public final P6 ipv6PrefixForShort(@Nonnull final byte[] array, final int startOffset, final int mask) {
+ if (mask == 0) {
+ // Easy case, reuse the template
+ return prefix6Factory.getTemplate();
+ }
+
+ Preconditions.checkArgument(mask > 0 && mask <= 128, "Invalid mask %s", mask);
+ final int size = (mask / Byte.SIZE) + ((mask % Byte.SIZE == 0) ? 0 : 1);
+
+ // Until we can instantiate an IPv6 address for a partial array, use a temporary buffer
+ byte[] tmp = new byte[INET6_LENGTH];
+ System.arraycopy(array, startOffset, tmp, 0, size);
+ return ipv6PrefixFor(tmp, mask);
+ }
+