<commit_before>/*
 * =============================================================================
 * 
 *   Copyright (c) 2008, The OP4J team (http://www.op4j.org)
 * 
 *   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 org.op4j.executables.functions;

import org.op4j.exceptions.NullTargetException;

/**
 * 
 * @since 1.0
 * 
 * @author <NAME>
 *
 */
public abstract class AbstractFunc<R, T> implements IFunc<R, T> {

    private boolean nullTargetAllowed= true;
    
    
    public AbstractFunc() {
        super();
    }

    
    protected boolean isNullTargetAllowed() {
        return this.nullTargetAllowed;
    }


    protected void setNullTargetAllowed(final boolean nullTargetAllowed) {
        this.nullTargetAllowed = nullTargetAllowed;
    }



    public final R execute(final T object) throws Exception {
        if (!this.nullTargetAllowed && object == null) {
            throw new NullTargetException();
        }
        return doExecute(object);
    }


    public abstract R doExecute(final T object) throws Exception;
    
    
    
}<commit_msg>Several changes made<commit_after>/*
 * =============================================================================
 * 
 *   Copyright (c) 2008, The OP4J team (http://www.op4j.org)
 * 
 *   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 org.op4j.executables.functions;

import org.op4j.exceptions.NullTargetException;

/**
 * 
 * @since 1.0
 * 
 * @author <NAME>
 *
 */
public abstract class AbstractFunc<R, T> implements IFunc<R, T> {

    private boolean nullTargetAllowed = true;
    
    
    public AbstractFunc() {
        super();
        // this allows subclasses to set the parameter by overriding isNullTargetAllowed() 
        this.nullTargetAllowed = isNullTargetAllowed();
    }

    
    protected boolean isNullTargetAllowed() {
        return this.nullTargetAllowed;
    }


    protected void setNullTargetAllowed(final boolean nullTargetAllowed) {
        this.nullTargetAllowed = nullTargetAllowed;
    }



    public final R execute(final T object) throws Exception {
        if (!isNullTargetAllowed() && object == null) {
            throw new NullTargetException();
        }
        return doExecute(object);
    }


    public abstract R doExecute(final T object) throws Exception;
    
    
    
}
{'fraction_non_alphanumeric': 0.16558349816332296, 'fraction_numerical': 0.007911839502684374, 'mean_word_length': 3.092485549132948, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '3108152', 'n_tokens_mistral': 937, 'n_tokens_neox': 897, 'n_words': 306}