<commit_before>/**
 *
 * Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); You may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.speedment.internal.core.platform.component.impl;

import com.speedment.db.crud.Create;
import com.speedment.db.crud.Delete;
import com.speedment.db.crud.Read;
import com.speedment.db.crud.Result;
import com.speedment.db.crud.Update;
import com.speedment.exception.SpeedmentException;
import com.speedment.component.CrudHandlerComponent;
import static java.util.Objects.requireNonNull;
import java.util.function.Function;
import java.util.stream.Stream;

/**
 *
 * @author <NAME>
 */
public final class CrudHandlerComponentImpl implements CrudHandlerComponent {
    
    private CreateMethod creator;
    private UpdateMethod updater;
    private DeleteMethod deleter;
    private ReadMethod reader;

    @Override
    public CrudHandlerComponent setCreator(CreateMethod creator) {
        this.creator = requireNonNull(creator);
        return this;
    }

    @Override
    public CrudHandlerComponent setUpdater(UpdateMethod updater) {
        this.updater = requireNonNull(updater);
        return this;
    }

    @Override
    public CrudHandlerComponent setDeleter(DeleteMethod deleter) {
        this.deleter = requireNonNull(deleter);
        return this;
    }

    @Override
    public CrudHandlerComponent setReader(ReadMethod reader) {
        this.reader = requireNonNull(reader);
        return this;
    }

    @Override
    public <T> T create(Create operation, Function<Result, T> mapper) throws SpeedmentException {
        return creator.apply(
            requireNonNull(operation), 
            requireNonNull(mapper)
        );
    }

    @Override
    public <T> T update(Update operation, Function<Result, T> mapper) throws SpeedmentException {
        return updater.apply(
            requireNonNull(operation), 
            requireNonNull(mapper)
        );
    }

    @Override
    public <T> void delete(Delete operation) throws SpeedmentException {
        deleter.apply(requireNonNull(operation));
    }

    @Override
    public <T> Stream<T> read(Read operation, Function<Result, T> mapper) throws SpeedmentException {
        return reader.apply(
            requireNonNull(operation), 
            requireNonNull(mapper)
        );
    }
}<commit_msg>Update CrudHandlerComponent to handle Speedment in constructor<commit_after>/**
 *
 * Copyright (c) 2006-2015, Speedment, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); You may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.speedment.internal.core.platform.component.impl;

import com.speedment.Speedment;
import com.speedment.db.crud.Create;
import com.speedment.db.crud.Delete;
import com.speedment.db.crud.Read;
import com.speedment.db.crud.Result;
import com.speedment.db.crud.Update;
import com.speedment.exception.SpeedmentException;
import com.speedment.component.CrudHandlerComponent;
import static java.util.Objects.requireNonNull;
import java.util.function.Function;
import java.util.stream.Stream;

/**
 *
 * @author <NAME>
 */
public final class CrudHandlerComponentImpl extends Apache2AbstractComponent implements CrudHandlerComponent {

    private CreateMethod creator;
    private UpdateMethod updater;
    private DeleteMethod deleter;
    private ReadMethod reader;

    public CrudHandlerComponentImpl(Speedment speedment) {
        super(speedment);
    }

    @Override
    public CrudHandlerComponent setCreator(CreateMethod creator) {
        this.creator = requireNonNull(creator);
        return this;
    }

    @Override
    public CrudHandlerComponent setUpdater(UpdateMethod updater) {
        this.updater = requireNonNull(updater);
        return this;
    }

    @Override
    public CrudHandlerComponent setDeleter(DeleteMethod deleter) {
        this.deleter = requireNonNull(deleter);
        return this;
    }

    @Override
    public CrudHandlerComponent setReader(ReadMethod reader) {
        this.reader = requireNonNull(reader);
        return this;
    }

    @Override
    public <T> T create(Create operation, Function<Result, T> mapper) throws SpeedmentException {
        return creator.apply(
            requireNonNull(operation),
            requireNonNull(mapper)
        );
    }

    @Override
    public <T> T update(Update operation, Function<Result, T> mapper) throws SpeedmentException {
        return updater.apply(
            requireNonNull(operation),
            requireNonNull(mapper)
        );
    }

    @Override
    public <T> void delete(Delete operation) throws SpeedmentException {
        deleter.apply(requireNonNull(operation));
    }

    @Override
    public <T> Stream<T> read(Read operation, Function<Result, T> mapper) throws SpeedmentException {
        return reader.apply(
            requireNonNull(operation),
            requireNonNull(mapper)
        );
    }
}

{'fraction_non_alphanumeric': 0.08355978260869565, 'fraction_numerical': 0.004245923913043478, 'mean_word_length': 3.292274052478134, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2149229', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1582, 'n_words': 454}