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

com.github.bloodshura.ignitium.ntv.pattern.primitive.AbstractValuePattern Maven / Gradle / Ivy

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

import com.github.bloodshura.ignitium.ntv.pattern.Pattern;
import com.github.bloodshura.ignitium.ntv.util.Buffer;

import javax.annotation.Nonnull;
import java.util.function.BiFunction;

public class AbstractValuePattern implements Pattern {
	private final BiFunction function;
	private final int size;
	private final E value;

	public AbstractValuePattern(@Nonnull E value, int size, @Nonnull BiFunction function) {
		this.function = function;
		this.size = size;
		this.value = value;
	}

	@Override
	public final int getSize() {
		return size;
	}

	@Override
	public boolean matches(@Nonnull Buffer buffer, long address) {
		return function.apply(buffer, address).equals(value);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy