IndexRowKeyBuilder { public IndexRowKey build() { checkState(order != null, "Sort order must be set on IndexRowBuilder."); List<byte[]> encodedRecords = Lists.newArrayList(); if (fields != null) { for (String column : tableSchema.getIndexSchema(indexName).getColumns()) { if (!fields.containsKey(column)) { continue; } ByteBuffer record = fields.get(column); if (record != null) { byte[] encodedRecord = encodeValue(record, tableSchema.getColumnSchema(column)); encodedRecords.add(order == SortOrder.Ascending ? encodedRecord : reverseValue(encodedRecord)); } else { encodedRecords.add(null); } } } if (order == SortOrder.Ascending) { return new AscIndexRowKey(tableId, indexId, encodedRecords, uuid); } return new DescIndexRowKey(tableId, indexId, encodedRecords, uuid); } private  IndexRowKeyBuilder(); static IndexRowKeyBuilder newBuilder(long tableId,
                                                long indexId); IndexRowKeyBuilder withSortOrder(SortOrder order); IndexRowKeyBuilder withRow(Row row,
                                      String indexName,
                                      TableSchema tableSchema); IndexRowKeyBuilder withQueryKey(QueryKey queryKey,
                                           TableSchema tableSchema); IndexRowKeyBuilder withUUID(UUID uuid); IndexRowKey build();  }
@Test(expected = IllegalStateException.class) public void testBuildWithoutSortOrderFails(){ builder.build(); }