<commit_before>package com.sageserpent.plutonium

/**
 * Created by Gerard on 03/09/2015.
 */

import scala.reflect.runtime.universe._



class ZeroOrOneIdentifiedItemBitemporalReferenceImplementation[Raw <: Identified: TypeTag](id: Raw#Id) extends IdentifiedItemsBitemporalReferenceImplementation[Raw](id) {
  override def interpret(scope: Bitemporal.IdentifiedItemsScope): Stream[Raw] = super.interpret(scope) match {
    case _ #:: _ => throw new RuntimeException(s"Id: '${id}' matches more than one item of type: '${implicitly[TypeTag[Raw]].tpe}'.")
    case zeroOrOneItems => zeroOrOneItems
  }
}<commit_msg>Fix for obvious error caused by my forgetting that the rhs operand of the #:: pattern constructor can be an *empty* stream. Doh. Now I have lots of test failures for other reasons ...<commit_after>package com.sageserpent.plutonium

/**
 * Created by Gerard on 03/09/2015.
 */

import scala.reflect.runtime.universe._



class ZeroOrOneIdentifiedItemBitemporalReferenceImplementation[Raw <: Identified: TypeTag](id: Raw#Id) extends IdentifiedItemsBitemporalReferenceImplementation[Raw](id) {
  override def interpret(scope: Bitemporal.IdentifiedItemsScope): Stream[Raw] = super.interpret(scope) match {
    case zeroOrOneItems @ (Stream.Empty | _#:: Stream.Empty) => zeroOrOneItems
    case _ => throw new RuntimeException(s"Id: '${id}' matches more than one item of type: '${implicitly[TypeTag[Raw]].tpe}'.")
  }
}
{'fraction_non_alphanumeric': 0.11632796075683252, 'fraction_numerical': 0.011212333566923615, 'mean_word_length': 5.611111111111111, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3322310', 'n_tokens_mistral': 453, 'n_tokens_neox': 427, 'n_words': 112}