<commit_before>package se.kth.infosys.smx.ladok3.internal;

import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

public class Ladok3UnmarshallerFactory {
  private static final Map<String, Unmarshaller> unmarshallers = new HashMap<>();

  /**
   * Since the split of the Ladok model into api- and event-jars, there are ObjectFactories with identical
   * FQCNs. So, if you for example send in "se.ladok.schema.resultat" and have the ladok-api-jar before
   * the event-jar in the CP, the ObjectFactory from the api-jar will be used and no Events can be unmarshalled.
   */
  @Deprecated
  public static Unmarshaller unmarshaller(String context) throws JAXBException, ClassNotFoundException {
    if (!unmarshallers.containsKey(context)) {
      JAXBContext jaxbContext = JAXBContext.newInstance(context);
      unmarshallers.put(context, jaxbContext.createUnmarshaller());
    }
    return unmarshallers.get(context);
  }

  public static Unmarshaller unmarshaller(String context, Class<?> eventClass) throws JAXBException {
    if (!unmarshallers.containsKey(context)) {
      JAXBContext jaxbContext = JAXBContext.newInstance(eventClass);
      unmarshallers.put(context, jaxbContext.createUnmarshaller());
    }
    return unmarshallers.get(context);
  }
}
<commit_msg>javadoc<commit_after>package se.kth.infosys.smx.ladok3.internal;

import java.util.HashMap;
import java.util.Map;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

public class Ladok3UnmarshallerFactory {
  private static final Map<String, Unmarshaller> unmarshallers = new HashMap<>();

  /**
   * @deprecated Since the split of the Ladok model into api- and event-jars, there are ObjectFactories with identical
   * FQCNs. So, if you for example send in "se.ladok.schema.resultat" and have the ladok-api-jar before
   * the event-jar in the CP, the ObjectFactory from the api-jar will be used and no Events can be unmarshalled.
   */
  @Deprecated
  public static Unmarshaller unmarshaller(String context) throws JAXBException {
    if (!unmarshallers.containsKey(context)) {
      JAXBContext jaxbContext = JAXBContext.newInstance(context);
      unmarshallers.put(context, jaxbContext.createUnmarshaller());
    }
    return unmarshallers.get(context);
  }

  public static Unmarshaller unmarshaller(String context, Class<?> eventClass) throws JAXBException {
    if (!unmarshallers.containsKey(context)) {
      JAXBContext jaxbContext = JAXBContext.newInstance(eventClass);
      unmarshallers.put(context, jaxbContext.createUnmarshaller());
    }
    return unmarshallers.get(context);
  }
}

{'fraction_non_alphanumeric': 0.09217264081931237, 'fraction_numerical': 0.001463057790782736, 'mean_word_length': 4.570264765784114, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '3026573', 'n_tokens_mistral': 847, 'n_tokens_neox': 858, 'n_words': 216}