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

com.github.bloodshura.ignitium.ntv.struct.CommonStructField Maven / Gradle / Ivy

The newest version!
package com.github.bloodshura.ignitium.ntv.struct;

import javax.annotation.Nonnull;
import java.util.function.BiConsumer;
import java.util.function.Function;

public class CommonStructField extends MutableStructField {
	private final Function reader;
	private final BiConsumer writer;

	public CommonStructField(@Nonnull MappedStruct struct, int offset, int size, @Nonnull Function reader, @Nonnull BiConsumer writer) {
		super(struct, offset, size);
		this.reader = reader;
		this.writer = writer;
	}

	@Nonnull
	@Override
	protected E read() {
		return reader.apply(getOffset());
	}

	@Override
	protected void write(@Nonnull E value) {
		writer.accept(getOffset(), value);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy