All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.server.resp.serialization.MapSerializer Maven / Gradle / Ivy

There is a newer version: 15.1.4.Final
Show newest version
package org.infinispan.server.resp.serialization;

import java.util.Map;

import org.infinispan.server.resp.ByteBufPool;

/**
 * Represent an unordered sequence of key-value tuples.
 *
 * 

* The prefix is a percent sign, followed by the base-10 representation of the number key-value tuples. Each key and value * follow the representation of the respective type. Therefore, the map is heterogeneous in its elements. *

* * @since 15.0 * @author José Bolina */ final class MapSerializer implements NestedResponseSerializer, SerializationHint.KeyValueHint> { static final MapSerializer INSTANCE = new MapSerializer(); @Override public void accept(Map map, ByteBufPool alloc, SerializationHint.KeyValueHint hint) { // RESP: %\r\n... ByteBufferUtils.writeNumericPrefix(RespConstants.MAP, map.size(), alloc); for (Map.Entry entry : map.entrySet()) { hint.key().serialize(entry.getKey(), alloc); hint.value().serialize(entry.getValue(), alloc); } } @Override public boolean test(Object object) { // Accept any map. return object instanceof Map; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy