List of usage examples for org.apache.cassandra.db.marshal ListType valueComparator
public AbstractType<T> valueComparator()
From source file:com.datastax.driver.core.CodecTest.java
License:Apache License
@Test(groups = "unit") public void testCustomList() throws Exception { ListType<?> listType = (ListType) Codec.getCodec(DataType.list(CUSTOM_FOO)); Assert.assertNotNull(listType);//from w w w . j a v a2 s.c o m Assert.assertTrue(listType.valueComparator() instanceof BytesType); }
From source file:com.datastax.driver.core.CodecTest.java
License:Apache License
@Test(groups = "unit") public void testListTypeCodec() throws Exception { Map<Name, ListType<?>> dateTypeListetTypeMap = new HashMap<Name, ListType<?>>(Codec.buildLists()); final Set<DataType> dataTypes = new HashSet<DataType>(allPrimitiveTypes()); // Special case: DataType varchar yields Codec.rawTypeToDataType(...) => text causing assertion fail // Solution: Remove DataType.varchar and check that it yields DataType.text Assert.assertTrue(dataTypes.remove(varchar())); final AbstractType<?> rawType = dateTypeListetTypeMap.get(varchar().getName()).valueComparator(); Assert.assertEquals(Codec.rawTypeToDataType(rawType), text()); dateTypeListetTypeMap.remove(varchar().getName()); for (DataType dataType : dataTypes) { final ListType<?> setType = dateTypeListetTypeMap.remove(dataType.getName()); Assert.assertEquals(Codec.rawTypeToDataType(setType.valueComparator()), dataType); }// w ww . j a v a 2s. c o m Assert.assertTrue(dateTypeListetTypeMap.isEmpty(), "All set types should have been tested: " + dateTypeListetTypeMap); }
From source file:com.tuplejump.stargate.cassandra.CassandraUtils.java
License:Apache License
public static AbstractType getValueValidator(AbstractType abstractType) { if (abstractType instanceof CollectionType) { if (abstractType instanceof MapType) { MapType mapType = (MapType) abstractType; return mapType.valueComparator(); } else if (abstractType instanceof SetType) { SetType setType = (SetType) abstractType; return setType.nameComparator(); } else if (abstractType instanceof ListType) { ListType listType = (ListType) abstractType; return listType.valueComparator(); }//from w w w. ja v a 2 s. c om } return abstractType; }