
org.wildfly.clustering.marshalling.protostream.util.MapEntryMarshaller Maven / Gradle / Ivy
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.wildfly.clustering.marshalling.protostream.util;
import java.io.IOException;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map;
import java.util.function.Function;
import org.infinispan.protostream.descriptors.WireType;
import org.wildfly.clustering.marshalling.protostream.ProtoStreamMarshaller;
import org.wildfly.clustering.marshalling.protostream.ProtoStreamReader;
import org.wildfly.clustering.marshalling.protostream.ProtoStreamWriter;
/**
* Marshaller for a {@link java.util.Map.Entry}
* @author Paul Ferraro
* @param the map entry type of this marshaller
*/
public class MapEntryMarshaller> implements ProtoStreamMarshaller {
private static final int KEY_INDEX = 1;
private static final int VALUE_INDEX = 2;
private final Class extends T> targetClass;
private final Function, T> factory;
@SuppressWarnings("unchecked")
public MapEntryMarshaller(Function, T> factory) {
this.targetClass = (Class) factory.apply(new SimpleEntry<>(null, null)).getClass();
this.factory = factory;
}
@Override
public T readFrom(ProtoStreamReader reader) throws IOException {
SimpleEntry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy