com.lambdaworks.redis.output.MapOutput Maven / Gradle / Ivy
// Copyright (C) 2011 - Will Glozer. All rights reserved.
package com.lambdaworks.redis.output;
import com.lambdaworks.redis.codec.RedisCodec;
import com.lambdaworks.redis.protocol.CommandOutput;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
/**
* {@link Map} of keys and values output.
*
* @param Key type.
* @param Value type.
*
* @author Will Glozer
*/
public class MapOutput extends CommandOutput> {
private K key;
public MapOutput(RedisCodec codec) {
super(codec, new HashMap());
}
@Override
public void set(ByteBuffer bytes) {
if (key == null) {
key = codec.decodeKey(bytes);
return;
}
V value = (bytes == null) ? null : codec.decodeValue(bytes);
output.put(key, value);
key = null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy