Source:
public void updateTokenAccessTime(UUID tokenUUID, long accessedTime, long inactiveTime, int ttl ){ Preconditions.checkNotNull(tokenUUID, "token UUID is required"); Preconditions.checkNotNull(accessedTime, "accessedTime is required"); Preconditions.checkNotNull(inactiveTime, "inactiveTime is required"); Preconditions.checkNotNull(ttl, "ttl is required"); logger.trace("updateTokenAccessTime, token UUID: {}, accessedTime: {}, inactiveTime: {}, ttl: {}", tokenUUID, accessedTime, inactiveTime, ttl); final BatchStatement batchStatement = new BatchStatement(); final Clause inKey = QueryBuilder.eq("key", DataType.uuid().serialize(tokenUUID, ProtocolVersion.NEWEST_SUPPORTED)); final Clause whereTokenAccessed = QueryBuilder.eq("column1", DataType.serializeValue(TOKEN_ACCESSED, ProtocolVersion.NEWEST_SUPPORTED)); final Clause whereTokenInactive = QueryBuilder.eq("column1", DataType.serializeValue(TOKEN_INACTIVE, ProtocolVersion.NEWEST_SUPPORTED)); final Assignment setAccessedTime = QueryBuilder.set("value", DataType.serializeValue(accessedTime, ProtocolVersion.NEWEST_SUPPORTED)); final Assignment setInactiveTime = QueryBuilder.set("value", DataType.serializeValue(inactiveTime, ProtocolVersion.NEWEST_SUPPORTED)); final Using usingTTL = QueryBuilder.ttl(ttl); if( inactiveTime != Long.MIN_VALUE){ batchStatement.add( QueryBuilder .update(TOKENS_TABLE) .with(setInactiveTime) .where(inKey).and(whereTokenInactive) .using(usingTTL) ); } batchStatement.add( QueryBuilder .update(TOKENS_TABLE) .with(setAccessedTime) .where(inKey).and(whereTokenAccessed) .using(usingTTL) ); session.execute(batchStatement); }

Target:
public void updateTokenAccessTime(UUID tokenUUID, long accessedTime, long inactiveTime, int ttl ){ Preconditions.checkNotNull(tokenUUID, "token UUID is required"); Preconditions.checkArgument(accessedTime > -1 , "accessedTime is required to be positive"); Preconditions.checkArgument(inactiveTime > -1 , "inactiveTime is required to be positive"); Preconditions.checkArgument(ttl > -1 , "ttl is required to be positive"); logger.trace("updateTokenAccessTime, token UUID: {}, accessedTime: {}, inactiveTime: {}, ttl: {}", tokenUUID, accessedTime, inactiveTime, ttl); final BatchStatement batchStatement = new BatchStatement(); final Clause inKey = QueryBuilder.eq("key", DataType.uuid().serialize(tokenUUID, ProtocolVersion.NEWEST_SUPPORTED)); final Clause whereTokenAccessed = QueryBuilder.eq("column1", DataType.serializeValue(TOKEN_ACCESSED, ProtocolVersion.NEWEST_SUPPORTED)); final Clause whereTokenInactive = QueryBuilder.eq("column1", DataType.serializeValue(TOKEN_INACTIVE, ProtocolVersion.NEWEST_SUPPORTED)); final Assignment setAccessedTime = QueryBuilder.set("value", DataType.serializeValue(accessedTime, ProtocolVersion.NEWEST_SUPPORTED)); final Assignment setInactiveTime = QueryBuilder.set("value", DataType.serializeValue(inactiveTime, ProtocolVersion.NEWEST_SUPPORTED)); final Using usingTTL = QueryBuilder.ttl(ttl); if( inactiveTime != Long.MIN_VALUE){ batchStatement.add( QueryBuilder .update(TOKENS_TABLE) .with(setInactiveTime) .where(inKey).and(whereTokenInactive) .using(usingTTL) ); } batchStatement.add( QueryBuilder .update(TOKENS_TABLE) .with(setAccessedTime) .where(inKey).and(whereTokenAccessed) .using(usingTTL) ); session.execute(batchStatement); }