<commit_before>package de.cosmocode.commons;

import org.apache.commons.lang.StringUtils;

/**
 * The {@link TrimMode} determines
 * how a {@link String} is being trimmed.
 * 
 * @author <NAME>
 */
public enum TrimMode {

    /**
     * Removes control characters (char &lt;= 32) from both
     * ends of this String, handling {@code null} by returning
     * {@code null}.
     * 
     * See {@link StringUtils#trim(String)} for more details.
     */
    NORMAL {
        
        @Override
        public String trim(String s) {
            return StringUtils.trim(s);
        }
        
    }, 
    
    /**
     * Removes control characters (char &lt;= 32) from both
     * ends of this String returning an empty String ("") if the String
     * is empty ("") after the trim or if it is {@code null}.
     * 
     * See {@link StringUtils#trimToEmpty(String)} for more details.
     */
    EMPTY {
        
        @Override
        public String trim(String s) {
            return StringUtils.trimToEmpty(s);
        }
        
    },
    
    /**
     * Removes control characters (char &lt;= 32) from both
     * ends of this String returning {@code null} if the String is
     * empty ("") after the trim or if it is {@code null}.
     * 
     * See {@link StringUtils#trimToNull(String)} for more details.
     */
    NULL {
        
        @Override
        public String trim(String s) {
            return StringUtils.trimToNull(s);
        }
        
    };
    
    /**
     * Trims the given {@link String}.
     * 
     * @param s the {@link String} being trimmed
     * @return the trimmed version of s
     */
    public abstract String trim(String s);

    /**
     * Trims the given {@link CharSequence}.
     * 
     * @param sequence the {@link CharSequence} being trimmed
     * @return the trimmed version of sequence
     */
    public CharSequence trim(CharSequence sequence) {
        return trim(sequence == null ? null : sequence.toString());
    }
    
}<commit_msg>made TrimMode implementing Function and Predicate<commit_after>package de.cosmocode.commons;

import org.apache.commons.lang.StringUtils;

import com.google.common.base.Function;
import com.google.common.base.Predicate;

/**
 * The {@link TrimMode} determines
 * how a {@link String} is being trimmed.
 * 
 * @author <NAME>
 */
public enum TrimMode implements Predicate<String>, Function<CharSequence, CharSequence> {

    /**
     * Removes control characters (char &lt;= 32) from both
     * ends of this String, handling {@code null} by returning
     * {@code null}.
     * 
     * See {@link StringUtils#trim(String)} for more details.
     */
    NORMAL {
        
        @Override
        public String trim(String s) {
            return StringUtils.trim(s);
        }
        
    }, 
    
    /**
     * Removes control characters (char &lt;= 32) from both
     * ends of this String returning an empty String ("") if the String
     * is empty ("") after the trim or if it is {@code null}.
     * 
     * See {@link StringUtils#trimToEmpty(String)} for more details.
     */
    EMPTY {
        
        @Override
        public String trim(String s) {
            return StringUtils.trimToEmpty(s);
        }
        
    },
    
    /**
     * Removes control characters (char &lt;= 32) from both
     * ends of this String returning {@code null} if the String is
     * empty ("") after the trim or if it is {@code null}.
     * 
     * See {@link StringUtils#trimToNull(String)} for more details.
     */
    NULL {
        
        @Override
        public String trim(String s) {
            return StringUtils.trimToNull(s);
        }
        
    };
    
    /**
     * Trims the given {@link String}.
     * 
     * @param s the {@link String} being trimmed
     * @return the trimmed version of s
     */
    public abstract String trim(String s);

    /**
     * Trims the given {@link CharSequence}.
     * 
     * @param sequence the {@link CharSequence} being trimmed
     * @return the trimmed version of sequence
     */
    public CharSequence trim(CharSequence sequence) {
        return trim(sequence == null ? null : sequence.toString());
    }
    
    /**
     * This is a kind of an adapter allowing
     * it to use a {@link TrimMode} as a {@link Function}.
     * 
     * <p>
     *   This method is delegating its work to {@link TrimMode#trim(CharSequence)}.
     * </p>
     * 
     * {@inheritDoc}
     */
    @Override
    public CharSequence apply(CharSequence from) {
        return trim(from);
    }
    
    /**
     * This implementation returns true if the given input is
     * trimmed using the semantics of this {@link TrimMode}.
     * 
     * {@inheritDoc}
     */
    @Override
    public boolean apply(String input) {
        return trim(input) == input;
    };
    
}
{'fraction_non_alphanumeric': 0.108298755186722, 'fraction_numerical': 0.0024896265560165973, 'mean_word_length': 1.986988847583643, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '7052240', 'n_tokens_mistral': 1392, 'n_tokens_neox': 1342, 'n_words': 456}