org.wildfly.clustering.marshalling.protostream.ScalarFieldMarshaller Maven / Gradle / Ivy
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*/
package org.wildfly.clustering.marshalling.protostream;
import java.io.IOException;
import org.infinispan.protostream.descriptors.WireType;
/**
* A field marshaller based on a scaler marshaller.
* @author Paul Ferraro
* @param the type of this marshaller
*/
public class ScalarFieldMarshaller implements FieldMarshaller {
private final ScalarMarshaller marshaller;
ScalarFieldMarshaller(ScalarMarshaller marshaller) {
this.marshaller = marshaller;
}
@Override
public T readFrom(ProtoStreamReader reader) throws IOException {
T result = this.marshaller.readFrom(reader);
while (!reader.isAtEnd()) {
int tag = reader.readTag();
reader.skipField(tag);
}
return result;
}
@Override
public void writeTo(ProtoStreamWriter writer, T value) throws IOException {
this.marshaller.writeTo(writer, value);
}
@Override
public Class extends T> getJavaClass() {
return this.marshaller.getJavaClass();
}
@Override
public WireType getWireType() {
return this.marshaller.getWireType();
}
}