Elffuss BraidHub

kikocis/java-driver public

Make TableMetadata.getIndexes() and TableMetadata.getViews() return Collection instead of List for consistency with similar methods.
Changesetd6b0dc0c73f3ebf43ff881a57bbe4bc2e8b1f0cf02d82947c3a96f4253ed0850
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-26 12:03 +01:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-26 12:03 +01:00
Parentsa159b8bff32c

Browse the files at this changeset

3 files changed

modified driver-core/src/main/java/com/datastax/driver/core/TableMetadata.java +8 −8
@@ -330,12 +330,12 @@
330330 }
331331
332332 /**
333- * Returns a list containing all the indexes of this table.
333+ * Returns all indexes based on this table.
334334 *
335- * @return a list containing the metadata for the indexes of this table.
335+ * @return all indexes based on this table.
336336 */
337- public List<IndexMetadata> getIndexes() {
338- return new ArrayList<IndexMetadata>(indexes.values());
337+ public Collection<IndexMetadata> getIndexes() {
338+ return Collections.unmodifiableCollection(indexes.values());
339339 }
340340
341341 /**
@@ -352,12 +352,12 @@
352352 }
353353
354354 /**
355- * Returns a list containing all the viewes of this table.
355+ * Returns all views based on this table.
356356 *
357- * @return a list containing the metadata for the viewes of this table.
357+ * @return all views based on this table.
358358 */
359- public List<MaterializedViewMetadata> getViews() {
360- return new ArrayList<MaterializedViewMetadata>(views.values());
359+ public Collection<MaterializedViewMetadata> getViews() {
360+ return Collections.unmodifiableCollection(views.values());
361361 }
362362
363363 void add(MaterializedViewMetadata view) {
modified driver-core/src/test/java/com/datastax/driver/core/MaterializedViewMetadataTest.java +1 −0
@@ -113,6 +113,7 @@
113113 TableMetadata table = cluster.getMetadata().getKeyspace(keyspace).getTable("\"T1\"");
114114 MaterializedViewMetadata mv = cluster.getMetadata().getKeyspace(keyspace).getMaterializedView("\"Mv1\"");
115115 assertThat(table).isNotNull().hasName("T1").hasMaterializedView(mv).hasNumberOfColumns(3);
116+ assertThat(table.getViews()).hasSize(1).containsOnly(mv);
116117 assertThat(table.getColumns().get(0)).isNotNull().hasName("theKey").isPartitionKey().hasType(cint());
117118 assertThat(table.getColumns().get(1)).isNotNull().hasName("the;Clustering").isClusteringColumn().hasType(cint());
118119 assertThat(table.getColumns().get(2)).isNotNull().hasName("the Value").isRegularColumn().hasType(cint());
modified driver-core/src/test/java/com/datastax/driver/core/TableMetadataTest.java +2 −4
@@ -20,8 +20,6 @@
2020 import org.testng.annotations.Test;
2121
2222 import java.nio.ByteBuffer;
23-import java.util.Collection;
24-import java.util.Collections;
2523
2624 import static com.datastax.driver.core.Assertions.assertThat;
2725 import static com.datastax.driver.core.ClusteringOrder.ASC;
@@ -462,9 +460,9 @@
462460 TableMetadata table_cd = cluster.getMetadata().getKeyspace(keyspace).getTable("test_cd");
463461
464462 assertThat(table_ab.getIndexes().size()).isEqualTo(1);
465- assertThat(table_ab.getIndexes().get(0).getName()).isEqualTo("test_b");
463+ assertThat(table_ab.getIndexes()).extracting("name").containsOnly("test_b");
466464 assertThat(table_cd.getIndexes().size()).isEqualTo(1);
467- assertThat(table_cd.getIndexes().get(0).getName()).isEqualTo("test_d");
465+ assertThat(table_cd.getIndexes()).extracting("name").containsOnly("test_d");
468466 }
469467
470468 /**