List of usage examples for org.apache.cassandra.db.marshal SetType nameComparator
public AbstractType<T> nameComparator()
From source file:com.datastax.driver.core.CodecTest.java
License:Apache License
@Test(groups = "unit") public void testCustomSet() throws Exception { SetType<?> setType = (SetType) Codec.getCodec(DataType.set(CUSTOM_FOO)); Assert.assertNotNull(setType);//from w w w. jav a 2 s . c o m Assert.assertEquals(setType.nameComparator().getClass(), BytesType.class); }
From source file:com.datastax.driver.core.CodecTest.java
License:Apache License
@Test(groups = "unit") public void testSetTypeCodec() throws Exception { Map<Name, SetType<?>> dateTypeSetTypeMap = new HashMap<Name, SetType<?>>(Codec.buildSets()); 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())); Assert.assertEquals(Codec.rawTypeToDataType(dateTypeSetTypeMap.get(varchar().getName()).nameComparator()), text());//from w w w . j a v a 2s . c o m dateTypeSetTypeMap.remove(varchar().getName()); for (DataType dataType : dataTypes) { final SetType<?> setType = dateTypeSetTypeMap.remove(dataType.getName()); Assert.assertEquals(Codec.rawTypeToDataType(setType.nameComparator()), dataType); } Assert.assertTrue(dateTypeSetTypeMap.isEmpty(), "All map types should have been tested: " + dateTypeSetTypeMap); }
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(); }//w ww .ja v a 2 s . c o m } return abstractType; }