public void addKeyOccurrence( KeyOccurrence occ ) {
    if ( null != occ ) {
      String sourceFolder = occ.getSourceFolder();
      if ( sourceFolder == null ) {
        throw new RuntimeException( "No source folder found for key: "
          + occ.getKey() + " in package " + occ.getMessagesPackage() );
      }
      String messagesPackage = occ.getMessagesPackage();

      // Do we have a map for the source folders?
      // If not, add one...
      //
      Map<String, List<KeyOccurrence>> packageOccurrences = sourcePackageOccurrences.get( sourceFolder );
      if ( packageOccurrences == null ) {
        packageOccurrences = new HashMap<>();
        sourcePackageOccurrences.put( sourceFolder, packageOccurrences );
      }

      // Do we have a map entry for the occurrences list in the source folder?
      // If not, add a list for the messages package
      //
      List<KeyOccurrence> occurrences = packageOccurrences.get( messagesPackage );
      if ( occurrences == null ) {
        occurrences = new ArrayList<>();
        occurrences.add( occ );
        packageOccurrences.put( messagesPackage, occurrences );
      } else {
        int index = Collections.binarySearch( occurrences, occ );
        if ( index < 0 ) {
          // Add it to the list, keep it sorted...
          //
          occurrences.add( -index - 1, occ );
        }
      }
    }
  }
@Test
  public void testAddKeyOccurrence() throws Exception {

    MessagesSourceCrawler messagesSourceCrawler =
      new MessagesSourceCrawler( null, null, null, null );

    // After adding an occurrence stating "Source Folder" and "Message Package", it should be retrieved
    final String thePackage = "a.b.c.Package";
    KeyOccurrence keyOccurrence =
      new KeyOccurrence( null, "Some Source Folder", thePackage, 1, 2, null, null, null );

    messagesSourceCrawler.addKeyOccurrence( keyOccurrence );

    // Check results
    List<KeyOccurrence> messagesPackage = messagesSourceCrawler.getOccurrencesForPackage( thePackage );
    assertNotNull( messagesPackage );
    assertEquals( 1, messagesPackage.size() );
    assertEquals( keyOccurrence, messagesPackage.get( 0 ) );
  }