package de.siphalor.was.dummy;

import de.siphalor.was.content.pack.ContentPack;
import de.siphalor.was.content.resource.Resource;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;

public class DummyContentPack implements ContentPack {
	public final String id;
	public final Map<String, String> content = new HashMap<>();

	public DummyContentPack(String id) {
		this.id = id;
	}

	@Override
	public @NotNull Stream<Resource> getResources(@NotNull String location, @NotNull String type) {
		return content.entrySet().stream().filter(e -> e.getKey().startsWith(location) && e.getKey().endsWith(type)).map(e -> new DummyResource(e.getKey(), e.getValue()));
	}

	@Override
	public @Nullable Resource getResource(@NotNull String location) {
		if (content.containsKey(location))
			return new DummyResource(location, content.get(location));
		return null;
	}

	@Override
	public @NotNull String getId() {
		return id;
	}
}
