<commit_before>package net.softwareminds.foosballbooking.service.repository;

import net.softwareminds.foosballbooking.service.domain.Booking;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;

public class MemoryBookingStorage implements BookingStorage {

  Map<String, Booking> store = new TreeMap<>();

  @Override
  public Booking storeBooking(Booking booking) {
    String id = UUID.randomUUID().toString();
    booking = new Booking(id, booking.getBegin(), booking.getEnd(), booking.getUser(), booking.getComment());
    store.put(id, booking);
    return booking;
  }

  @Override
  public void deleteBooking(String bookingId) {
    store.remove(bookingId);
  }

  @Override
  public Booking getBooking(String bookingId) {
    return store.get(bookingId);
  }

  @Override
  public List<Booking> getAllBookings() {
    return new ArrayList(store.values());
  }
}<commit_msg>MemoryBookingStorage sorts the booking by begin.<commit_after>package net.softwareminds.foosballbooking.service.repository;

import net.softwareminds.foosballbooking.service.domain.Booking;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;

public class MemoryBookingStorage implements BookingStorage {

  Map<String, Booking> store = new TreeMap<>();

  @Override
  public Booking storeBooking(Booking booking) {
    String id = UUID.randomUUID().toString();
    booking = new Booking(id, booking.getBegin(), booking.getEnd(), booking.getUser(), booking.getComment());
    store.put(id, booking);
    return booking;
  }

  @Override
  public void deleteBooking(String bookingId) {
    store.remove(bookingId);
  }

  @Override
  public Booking getBooking(String bookingId) {
    return store.get(bookingId);
  }

  @Override
  public List<Booking> getAllBookings() {
    List<Booking> bookingList = new ArrayList(store.values());
    Collections.sort(bookingList, (Booking o1, Booking o2) -> o1.getBegin().compareTo(o2.getBegin()));

    return bookingList;
  }
}
{'fraction_non_alphanumeric': 0.11639962299717248, 'fraction_numerical': 0.001885014137606032, 'mean_word_length': 4.769021739130435, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 11, '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': '3114866', 'n_tokens_mistral': 664, 'n_tokens_neox': 653, 'n_words': 142}