package ru.dbotthepony.mc.otm.storage.optics

import ru.dbotthepony.mc.otm.storage.IStorageAcceptor
import ru.dbotthepony.mc.otm.storage.IStorageComponent
import ru.dbotthepony.mc.otm.storage.IStorageProvider
import ru.dbotthepony.mc.otm.storage.StorageStack
import java.util.function.IntSupplier

class ModifyPriority<S : StorageStack<S>>(
	private val parent: IStorageComponent<S>,
	insertPriority: IntSupplier,
	extractPriority: IntSupplier
) : IStorageComponent<S>, IStorageAcceptor<S> by InsertPriority(parent, insertPriority), IStorageProvider<S> by ExtractPriority(parent, extractPriority) {
	override fun equals(other: Any?): Boolean {
		return other is ModifyPriority<*> && parent == other.parent
	}

	override fun hashCode(): Int {
		return parent.hashCode()
	}

	override fun toString(): String {
		return "ModifyPriority[$parent with $insertPriority and $extractPriority]"
	}

	override val storageType: StorageStack.Type<S>
		get() = parent.storageType
}
