<commit_before>package net.zomis.cardshifter.ecs.resources;

import net.zomis.cardshifter.ecs.base.Entity;

public class ResourceRetreiver {

	private final ECSResource resource;

	private ResourceRetreiver(ECSResource resource) {
		this.resource = resource;
	}
	
	public static ResourceRetreiver forResource(ECSResource resource) {
		return new ResourceRetreiver(resource);
	}

	public int getFor(Entity entity) {
		return entity.getComponent(ECSResourceMap.class).getResource(resource).get();
	}

	public ECSResourceData resFor(Entity entity) {
		return entity.getComponent(ECSResourceMap.class).getResource(resource);
	}

}
<commit_msg>Refactored ResourceRetriever a bit to be able to throw NPE<commit_after>package net.zomis.cardshifter.ecs.resources;

import java.util.Objects;

import net.zomis.cardshifter.ecs.base.Entity;

public class ResourceRetreiver {

	private final ECSResource resource;

	private ResourceRetreiver(ECSResource resource) {
		this.resource = resource;
	}
	
	public static ResourceRetreiver forResource(ECSResource resource) {
		return new ResourceRetreiver(resource);
	}

	public int getFor(Entity entity) {
		return resMap(entity).getResource(resource).get();
	}

	private ECSResourceMap resMap(Entity entity) {
		ECSResourceMap map = entity.getComponent(ECSResourceMap.class);
		return Objects.requireNonNull(map, entity + " does not have a resource component");
	}

	public ECSResourceData resFor(Entity entity) {
		return resMap(entity).getResource(resource);
	}

}

{'fraction_non_alphanumeric': 0.08866666666666667, 'fraction_numerical': 0.0, 'mean_word_length': 5.761261261261262, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '144561', 'n_tokens_mistral': 486, 'n_tokens_neox': 458, 'n_words': 99}