<commit_before>package com.getbase.services;

import com.getbase.http.HttpClient;
import com.getbase.models.Lead;
import com.getbase.serializer.JsonDeserializer;
import com.getbase.serializer.JsonSerializer;
import com.getbase.serializer.Views;

import java.util.*;

import static com.getbase.utils.Precondition.*;


public class LeadsService extends BaseService {
    public LeadsService(HttpClient httpClient) {
        super(httpClient);
    }

    public List<Lead> list(Map<String, Object> params) {
        return JsonDeserializer.deserializeList(this.httpClient.get("/leads", params).getBody(), Lead.class);
    }

    public List<Lead> list(SearchCriteria criteria) {
        return list(criteria.build());
    }


    public Lead get(long leadId) {
        return JsonDeserializer.deserialize(this.httpClient.get(String.format(Locale.US, "/leads/%d", leadId), null).getBody(), Lead.class);
    }

    public Lead create(Lead lead) {
        checkNotNull(lead, "lead parameter must not be null");


        String serialized = JsonSerializer.serialize(lead, Views.ReadWrite.class);
        return JsonDeserializer.deserialize(this.httpClient.post("/leads", serialized).getBody(), Lead.class);
    }

    public Lead create(Map<String, Object> attributes) {
        checkNotNull(attributes, "attributes parameter must not be null");

        String serialized = JsonSerializer.serialize(attributes);
        return JsonDeserializer.deserialize(this.httpClient.post("/leads", serialized).getBody(), Lead.class);
    }

    public Lead update(Lead lead) {
        checkNotNull(lead, "lead parameter must not be null");
        checkNotNull(lead.getId(), "lead must have id attribute set");
        checkArgument(lead.getId() > 0, "lead id must be a valid id");

        String serialized = JsonSerializer.serialize(lead, Views.ReadWrite.class);
        return JsonDeserializer.deserialize(this.httpClient.put(String.format(Locale.US, "/leads/%d", lead.getId()), serialized).getBody(), Lead.class);
    }


    public Lead update(long leadId, Map<String, Object> attributes) {
        checkNotNull(attributes, "attributes parameter must not be null");
        checkArgument(leadId > 0, "leadId must be a valid id");

        String serialized = JsonSerializer.serialize(attributes);
        return JsonDeserializer.deserialize(this.httpClient.put(String.format(Locale.US, "/leads/%d", leadId), serialized).getBody(), Lead.class);
    }

    public boolean delete(long leadId) {
       checkArgument(leadId > 0, "leadId must be a valid id");

       return this.httpClient.delete(String.format(Locale.US, "/leads/%d", leadId), null).getHttpStatus() == 204;
    }

    public static class SearchCriteria {
        private Map<String, Object> queryParams;

        public SearchCriteria() {
            this.queryParams = new HashMap<String, Object>();
        }
<commit_msg>Drop String.format and use string concatenation instead<commit_after>package com.getbase.services;

import com.getbase.http.HttpClient;
import com.getbase.models.Lead;
import com.getbase.serializer.JsonDeserializer;
import com.getbase.serializer.JsonSerializer;
import com.getbase.serializer.Views;

import java.util.*;

import static com.getbase.utils.Precondition.*;


public class LeadsService extends BaseService {
    public LeadsService(HttpClient httpClient) {
        super(httpClient);
    }

    public List<Lead> list(Map<String, Object> params) {
        return JsonDeserializer.deserializeList(this.httpClient.get("/leads", params).getBody(), Lead.class);
    }

    public List<Lead> list(SearchCriteria criteria) {
        return list(criteria.build());
    }


    public Lead get(long leadId) {
        return JsonDeserializer.deserialize(this.httpClient.get("/leads/" + leadId, null).getBody(), Lead.class);
    }

    public Lead create(Lead lead) {
        checkNotNull(lead, "lead parameter must not be null");


        String serialized = JsonSerializer.serialize(lead, Views.ReadWrite.class);
        return JsonDeserializer.deserialize(this.httpClient.post("/leads", serialized).getBody(), Lead.class);
    }

    public Lead create(Map<String, Object> attributes) {
        checkNotNull(attributes, "attributes parameter must not be null");

        String serialized = JsonSerializer.serialize(attributes);
        return JsonDeserializer.deserialize(this.httpClient.post("/leads", serialized).getBody(), Lead.class);
    }

    public Lead update(Lead lead) {
        checkNotNull(lead, "lead parameter must not be null");
        checkNotNull(lead.getId(), "lead must have id attribute set");
        checkArgument(lead.getId() > 0, "lead id must be a valid id");

        String serialized = JsonSerializer.serialize(lead, Views.ReadWrite.class);
        return JsonDeserializer.deserialize(this.httpClient.put("/leads/" + lead.getId(), serialized).getBody(), Lead.class);
    }


    public Lead update(long leadId, Map<String, Object> attributes) {
        checkNotNull(attributes, "attributes parameter must not be null");
        checkArgument(leadId > 0, "leadId must be a valid id");

        String serialized = JsonSerializer.serialize(attributes);
        return JsonDeserializer.deserialize(this.httpClient.put("/leads/" + leadId, serialized).getBody(), Lead.class);
    }

    public boolean delete(long leadId) {
       checkArgument(leadId > 0, "leadId must be a valid id");

       return this.httpClient.delete("/leads/" + leadId, null).getHttpStatus() == 204;
    }

    public static class SearchCriteria {
        private Map<String, Object> queryParams;

        public SearchCriteria() {
            this.queryParams = new HashMap<String, Object>();
        }

{'fraction_non_alphanumeric': 0.11800914526908196, 'fraction_numerical': 0.002110446711220542, 'mean_word_length': 3.6691297208538587, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, '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': '821957', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1535, 'n_words': 380}