org.eclipse.store.storage.restadapter.types.ValueReaderPrimitive Maven / Gradle / Ivy
package org.eclipse.store.storage.restadapter.types;
/*-
* #%L
* EclipseStore Storage REST Adapter
* %%
* Copyright (C) 2023 MicroStream Software
* %%
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
* #L%
*/
import org.eclipse.serializer.persistence.binary.types.Binary;
import org.eclipse.serializer.persistence.binary.types.BinaryPersistence;
import org.eclipse.serializer.persistence.types.PersistenceTypeDefinitionMember;
public class ValueReaderPrimitive implements ValueReader
{
///////////////////////////////////////////////////////////////////////////
// instance fields //
////////////////////
private final PersistenceTypeDefinitionMember typeDefinition;
///////////////////////////////////////////////////////////////////////////
// constructors //
/////////////////
public ValueReaderPrimitive(final PersistenceTypeDefinitionMember member)
{
super();
this.typeDefinition = member;
}
///////////////////////////////////////////////////////////////////////////
// methods //
////////////
@Override
public Object readValue(final Binary binary, final long offset)
{
return ViewerBinaryPrimitivesReader.readPrimitive(this.typeDefinition.type(), binary, offset);
}
@Override
public long getBinarySize(final Binary binary, final long offset)
{
return BinaryPersistence.resolvePrimitiveFieldBinaryLength(this.typeDefinition.type());
}
}