<commit_before>package br.com.wehavescience.spark.sample;

import br.com.wehavescience.spark.sample.exceptions.ResourceAlreadyExistsException;
import br.com.wehavescience.spark.sample.exceptions.ResourceNotFoundException;
import br.com.wehavescience.spark.sample.exceptions.RestfulException;
import br.com.wehavescience.spark.sample.model.Customer;
import br.com.wehavescience.spark.sample.services.CustomerService;
import br.com.wehavescience.spark.sample.transformers.JsonTransformer;

import static br.com.wehavescience.spark.sample.utils.JsonUtils.asObject;
import static java.lang.Integer.parseInt;
import static spark.Spark.*;

/**
 * @author <NAME> <<EMAIL>>
 */
public class RoutesStarter {
    private static final String CONTENT_TYPE = "application/json";

    public static void main(String[] args) {
        CustomerService service = new CustomerService();

        setPort(9090);

        //listing all
        get("/customers", CONTENT_TYPE, (request, response) -> service.findAll(), new JsonTransformer());

        //getting some specific customer
        get("/customers/:id", CONTENT_TYPE, (request, response) -> {
            Customer customer = service.findById(parseInt(request.params(":id")));

            if (customer == null) {
                throw new ResourceNotFoundException();
            }

            return customer;
        }, new JsonTransformer());

        //adding a customer to the list
        post("/customers/:id", CONTENT_TYPE, (request, response) -> {
            int id = parseInt(request.params(":id"));
            if (service.findById(id) != null) {
                throw new ResourceAlreadyExistsException();
            }

            Customer customer = asObject(request.body(), Customer.class);
            customer.setId(id);
            service.save(customer);
            return customer;
        }, new JsonTransformer());

        //updating a customer of the list
        put("/customers/:id", CONTENT_TYPE, (request, response) -> {
            Customer customer = service.findById(parseInt(request.params(":id")));

            if (customer == null) {
                new ResourceNotFoundException();<commit_msg>removing return in a lambda statement<commit_after>package br.com.wehavescience.spark.sample;

import br.com.wehavescience.spark.sample.exceptions.ResourceAlreadyExistsException;
import br.com.wehavescience.spark.sample.exceptions.ResourceNotFoundException;
import br.com.wehavescience.spark.sample.exceptions.RestfulException;
import br.com.wehavescience.spark.sample.model.Customer;
import br.com.wehavescience.spark.sample.services.CustomerService;
import br.com.wehavescience.spark.sample.transformers.JsonTransformer;

import static br.com.wehavescience.spark.sample.utils.JsonUtils.asObject;
import static java.lang.Integer.parseInt;
import static spark.Spark.*;

/**
 * @author <NAME> <<EMAIL>>
 */
public class RoutesStarter {
    private static final String CONTENT_TYPE = "application/json";

    public static void main(String[] args) {
        CustomerService service = new CustomerService();

        setPort(9090);

        //listing all
        get("/customers", CONTENT_TYPE, (request, response) -> service.findAll(), new JsonTransformer());

        //getting a specific customer
        get("/customers/:id", CONTENT_TYPE, (request, response) -> {
            Customer customer = service.findById(parseInt(request.params(":id")));

            if (customer == null) {
                throw new ResourceNotFoundException();
            }

            return customer;
        }, new JsonTransformer());

        //adding a customer to the list
        post("/customers/:id", CONTENT_TYPE, (request, response) -> {
            int id = parseInt(request.params(":id"));
            if (service.findById(id) != null) {
                throw new ResourceAlreadyExistsException();
            }

            Customer customer = asObject(request.body(), Customer.class);
            customer.setId(id);
            service.save(customer);
            return customer;
        }, new JsonTransformer());

        //updating a customer of the list
        put("/customers/:id", CONTENT_TYPE, (request, response) -> {
            Customer customer = service.findById(parseInt(request.params(":id")));

            if (customer == null) {
                new ResourceNotFoundException();
{'fraction_non_alphanumeric': 0.11999084039386307, 'fraction_numerical': 0.0018319212273872224, 'mean_word_length': 2.9, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 17, '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': '258179', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1162, 'n_words': 248}