<commit_before>package lv.ctco.cukesrest.gadgets;

import lv.ctco.cukesrest.common.*;
import lv.ctco.cukesrest.gadgets.dto.*;

import javax.inject.*;
import java.util.*;
import java.util.stream.*;

public class DummyGadgetService {

    @Inject
    InMemoryStorage storage;

    public Collection<GadgetDto> searchGadgets(Integer top, Integer skip) {
        Stream<GadgetDto> stream = storage.getGadgets().values().stream();
        if (skip != null) {
            stream = stream.skip(skip);
        }
        if (top != null) {
            stream = stream.limit(top);
        }
        return stream.collect(Collectors.<GadgetDto>toList());
    }

    public GadgetDto getGadget(Integer id) {
        return storage.getGadgets().get(id);
    }

    public Integer addGadget(GadgetDto gadget) {
        if (gadget == null || !isValidType(gadget)) return null;

        Set<Integer> gadgetIds = storage.getGadgets().keySet();
        Integer newId = Collections.max(gadgetIds) + 1;
        gadget.setId(newId);
        gadget.setUpdatedDate(null);
        gadget.setCreatedDate(new Date());

        storage.getGadgets().put(newId, gadget);
        return newId;
    }

    public boolean updateGadget(Integer id, GadgetDto updated) {
        GadgetDto gadget = storage.getGadgets().get(id);
        if (gadget == null || updated == null || !isValidType(updated)) return false;

        gadget.setName(updated.getName());
        gadget.setType(updated.getType());
        gadget.setOwner(updated.getOwner());
        gadget.setUpdatedDate(new Date());
        return true;
    }<commit_msg>Rolled back JDK 8 usage in cukes-rest-sample<commit_after>package lv.ctco.cukesrest.gadgets;

import lv.ctco.cukesrest.common.*;
import lv.ctco.cukesrest.gadgets.dto.*;

import javax.inject.*;
import java.util.*;

public class DummyGadgetService {

    @Inject
    InMemoryStorage storage;

    public Collection<GadgetDto> searchGadgets(Integer top, Integer skip) {
        Iterator<GadgetDto> iterator = storage.getGadgets().values().iterator();
        if (skip != null) {
            for (int i = 0; i < skip; i++) iterator.next();
        }
        List<GadgetDto> result = new ArrayList<GadgetDto>();
        for (int i = 0; (top == null || i < top) && iterator.hasNext(); i++) {
            result.add(iterator.next());
        }
        return result;
    }

    public GadgetDto getGadget(Integer id) {
        return storage.getGadgets().get(id);
    }

    public Integer addGadget(GadgetDto gadget) {
        if (gadget == null || !isValidType(gadget)) return null;

        Set<Integer> gadgetIds = storage.getGadgets().keySet();
        Integer newId = Collections.max(gadgetIds) + 1;
        gadget.setId(newId);
        gadget.setUpdatedDate(null);
        gadget.setCreatedDate(new Date());

        storage.getGadgets().put(newId, gadget);
        return newId;
    }

    public boolean updateGadget(Integer id, GadgetDto updated) {
        GadgetDto gadget = storage.getGadgets().get(id);
        if (gadget == null || updated == null || !isValidType(updated)) return false;

        gadget.setName(updated.getName());
        gadget.setType(updated.getType());
        gadget.setOwner(updated.getOwner());
        gadget.setUpdatedDate(new Date());
        return true;
    }
{'fraction_non_alphanumeric': 0.13169099756690997, 'fraction_numerical': 0.0015206812652068127, 'mean_word_length': 2.7935409457900806, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 12, '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': '6650963', 'n_tokens_mistral': 1032, 'n_tokens_neox': 1064, 'n_words': 208}