/** Returns a {@code LockDescriptor} instance for the given lock ID. */ @SuppressWarnings("checkstyle:jdkStandardCharsets") // StandardCharsets only in JDK 1.7+ public static LockDescriptor of(String lockId) { Preconditions.checkNotNull(lockId, "lockId should not be null"); Preconditions.checkArgument(!Strings.isNullOrEmpty(lockId)); return new LockDescriptor(lockId.getBytes(Charsets.UTF_8)); } }
/** Returns a {@code LockDescriptor} instance for the given table and row. */ public static LockDescriptor of(String tableName, byte[] rowName) { Preconditions.checkArgument(!Strings.isNullOrEmpty(tableName)); Preconditions.checkNotNull(rowName, "rowName should not be null"); byte[] tableBytes = tableName.getBytes(); byte[] bytes = new byte[tableBytes.length + 1 + rowName.length]; System.arraycopy(tableBytes, 0, bytes, 0, tableBytes.length); System.arraycopy(rowName, 0, bytes, tableBytes.length + 1, rowName.length); return new LockDescriptor(bytes); } }
/** Returns a {@code LockDescriptor} instance for the given table, row, and column. */ public static LockDescriptor of(String tableName, byte[] rowName, byte[] colName) { Preconditions.checkArgument(!Strings.isNullOrEmpty(tableName)); Preconditions.checkNotNull(rowName, "rowName should not be null"); Preconditions.checkNotNull(colName, "colName should not be null"); byte[] tableBytes = tableName.getBytes(); byte[] bytes = new byte[tableBytes.length + 1 + rowName.length + 1 + colName.length]; System.arraycopy(tableBytes, 0, bytes, 0, tableBytes.length); System.arraycopy(rowName, 0, bytes, tableBytes.length + 1, rowName.length); System.arraycopy(colName, 0, bytes, tableBytes.length + 1 + rowName.length + 1, colName.length); return new LockDescriptor(bytes); } }
/** Returns a {@code LockDescriptor} instance for the given lock ID. */ public static LockDescriptor of(byte[] bytes) { Preconditions.checkNotNull(bytes, "bytes cannot be null"); return new LockDescriptor(bytes.clone()); } }
/** Returns a {@code LockDescriptor} instance for the given table and row. */ public static LockDescriptor of(long timestamp) { return new LockDescriptor(Longs.toByteArray(timestamp)); } }
/** Returns a {@code LockDescriptor} instance for the given lock ID. */ @SuppressWarnings("checkstyle:jdkStandardCharsets") // StandardCharsets only in JDK 1.7+ public static LockDescriptor of(String lockId) { Preconditions.checkNotNull(lockId, "lockId should not be null"); Preconditions.checkArgument(!Strings.isNullOrEmpty(lockId)); return new LockDescriptor(lockId.getBytes(Charsets.UTF_8)); } }
/** Returns a {@code LockDescriptor} instance for the given table and row. */ public static LockDescriptor of(String tableName, byte[] rowName) { Preconditions.checkArgument(!Strings.isNullOrEmpty(tableName)); Preconditions.checkNotNull(rowName, "rowName should not be null"); byte[] tableBytes = tableName.getBytes(); byte[] bytes = new byte[tableBytes.length + 1 + rowName.length]; System.arraycopy(tableBytes, 0, bytes, 0, tableBytes.length); System.arraycopy(rowName, 0, bytes, tableBytes.length + 1, rowName.length); return new LockDescriptor(bytes); } }
/** Returns a {@code LockDescriptor} instance for the given table, row, and column. */ public static LockDescriptor of(String tableName, byte[] rowName, byte[] colName) { Preconditions.checkArgument(!Strings.isNullOrEmpty(tableName)); Preconditions.checkNotNull(rowName, "rowName should not be null"); Preconditions.checkNotNull(colName, "colName should not be null"); byte[] tableBytes = tableName.getBytes(); byte[] bytes = new byte[tableBytes.length + 1 + rowName.length + 1 + colName.length]; System.arraycopy(tableBytes, 0, bytes, 0, tableBytes.length); System.arraycopy(rowName, 0, bytes, tableBytes.length + 1, rowName.length); System.arraycopy(colName, 0, bytes, tableBytes.length + 1 + rowName.length + 1, colName.length); return new LockDescriptor(bytes); } }
/** Returns a {@code LockDescriptor} instance for the given table and row. */ public static LockDescriptor of(long timestamp) { return new LockDescriptor(Longs.toByteArray(timestamp)); } }
/** Returns a {@code LockDescriptor} instance for the given lock ID. */ public static LockDescriptor of(byte[] bytes) { Preconditions.checkNotNull(bytes, "bytes cannot be null"); return new LockDescriptor(bytes.clone()); } }