<commit_before>/*
 * =============================================================================
 * 
 *   Copyright (c) 2010, 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.functions;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.LocaleUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.apache.commons.lang.time.DateUtils;

/**
 * 
 * @since 1.0
 * 
 * @author <NAME>
 *
 */
public final class FnCalendar {

    
    private static final Function<Timestamp,Calendar> TIMESTAMP_TO_CALENDAR = new TimestampToCalendar();
    private static final Function<Long,Calendar> TIME_IN_MILLIS_TO_CALENDAR = new TimeInMillisToCalendar();
    
    private static final Function<List<Integer>,Calendar> FIELD_INTEGER_LIST_TO_CALENDAR = new FieldIntegerListToCalendar();
    private static final Function<Integer[],Calendar> FIELD_INTEGER_ARRAY_TO_CALENDAR = new FieldIntegerArrayToCalendar();
    private static final Function<List<String>,Calendar> FIELD_STRING_LIST_TO_CALENDAR = new FieldStringListToCalendar();
    private static final Function<String[],Calendar> FIELD_STRING_ARRAY_TO_CALENDAR = new FieldStringArrayToCalendar();

    
    
	private FnCalendar() {
		super();           
	}
	
	

	public static final Function<Calendar,Calendar> add(final int calendarField, final int amount) {
        return new Add(calendarField, amount);
    }
	
    public static final Function<Calendar,Calendar> addDays(final int amount) {
        return new Add(Calendar.DATE, amount);
    }
    
    public static final Function<Calendar,Calendar> addHours(final int amount) {
        return new Add(Calendar.HOUR, amount);
    }
    
    public static final Function<Calendar,Calendar> addMilliseconds(final int amount) {
        return new Add(Calendar.MILLISECOND, amount);
    }
    
    public static final Function<Calendar,Calendar> addMinutes(final int amount) {
        return new Add(Calendar.MINUTE, amount);
    }
    
    public static final Function<Calendar,Calendar> addMonths(final int amount) {
        return new Add(Calendar.MONTH, amount);
    }
    
    public static final Function<Calendar,Calendar> addWeeks(final int amount) {
        return new Add(Calendar.WEEK_OF_YEAR, amount);
    }
    
    public static final Function<Calendar,Calendar> addYears(final int amount) {
        return new Add(Calendar.YEAR, amount);
    }

    public static final Function<Calendar,Calendar> set(final int calendarField, final int value) {
        return new Set(calendarField, value);
    }
    
    public static final Function<Calendar,Calendar> setDay(final int value) {
        return new Set(Calendar.DATE, value);
    }
    
    public static final Function<Calendar,Calendar> setHour(final int value) {
        return new Set(Calendar.HOUR, value);
    }
    
    public static final Function<Calendar,Calendar> setMillisecond(final int value) {
        return new Set(Calendar.MILLISECOND, value);
    }
    
    public static final Function<Calendar,Calendar> setMinute(final int value) {
        return new Set(Calendar.MINUTE, value);
    }
    
    public static final Function<Calendar,Calendar> setMonth(final int value) {
        return new Set(Calendar.MONTH, value);
    }
    
    public static final Function<Calendar,Calendar> setWeek(final int value) {
        return new Set(Calendar.WEEK_OF_YEAR, value);
    }
    
    public static final Function<Calendar,Calendar> setYear(final int value) {
        return new Set(Calendar.YEAR, value);
    }

    public static final Function<Calendar,Calendar> round(final int calendarField) {
        return new Round(calendarField);
    }

    public static final Function<Calendar,Calendar> truncate(final int calendarField) {
        return new Truncate(calendarField);
    }

    public static final Function<Calendar,Boolean> before(final Calendar calendar) {
        return new Before(calendar);
    }

    public static final Function<Calendar,Boolean> after(final Calendar calendar) {
        return new After(calendar);
    }
    
    
    
    public static final Function<Calendar,String> toStr(final String pattern) {
        return new ToString(pattern);
    }
    <commit_msg>Several changes made<commit_after>/*
 * =============================================================================
 * 
 *   Copyright (c) 2010, 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.functions;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.LocaleUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
import org.apache.commons.lang.time.DateUtils;

/**
 * 
 * @since 1.0
 * 
 * @author <NAME>
 *
 */
public final class FnCalendar {

    
    private static final Function<Timestamp,Calendar> TIMESTAMP_TO_CALENDAR = new TimestampToCalendar();
    private static final Function<Long,Calendar> TIME_IN_MILLIS_TO_CALENDAR = new TimeInMillisToCalendar();
    
    private static final Function<List<Integer>,Calendar> FIELD_INTEGER_LIST_TO_CALENDAR = new FieldIntegerListToCalendar();
    private static final Function<Integer[],Calendar> FIELD_INTEGER_ARRAY_TO_CALENDAR = new FieldIntegerArrayToCalendar();
    private static final Function<List<String>,Calendar> FIELD_STRING_LIST_TO_CALENDAR = new FieldStringListToCalendar();
    private static final Function<String[],Calendar> FIELD_STRING_ARRAY_TO_CALENDAR = new FieldStringArrayToCalendar();

    
    
	private FnCalendar() {
		super();           
	}
	
	

	/**
	 * <p>
	 * Modifies a Calendar by adding a positive or negative amount to one of its
	 * fields. 
	 * </p>
	 * <p>
	 * Fields are specified by means of <tt>java.util.Calendar</tt> constants, like
	 * <tt>FnCalendar.add(Calendar.DAY_OF_MONTH, 1)</tt>.
	 * </p>
	 * 
	 * @param calendarField the field that will be modified (java.util.Calendar constant).
	 * @param amount the positive or negative amount to be added
	 * @return the modified Calendar
	 */
	public static final Function<Calendar,Calendar> add(final int calendarField, final int amount) {
        return new Add(calendarField, amount);
    }

	
    /**
     * <p>
     * Modifies a Calendar by adding a positive or negative amount to one the
     * "day" property (<tt>java.util.Calendar.DATE</tt>). 
     * </p>
     * 
     * @param amount the positive or negative amount to be added
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> addDays(final int amount) {
        return new Add(Calendar.DATE, amount);
    }
    

    /**
     * <p>
     * Modifies a Calendar by adding a positive or negative amount to one the
     * "hour" property (<tt>java.util.Calendar.HOUR</tt>). 
     * </p>
     * 
     * @param amount the positive or negative amount to be added
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> addHours(final int amount) {
        return new Add(Calendar.HOUR, amount);
    }

    
    /**
     * <p>
     * Modifies a Calendar by adding a positive or negative amount to one the
     * "millisecond" property (<tt>java.util.Calendar.MILLISECOND</tt>). 
     * </p>
     * 
     * @param amount the positive or negative amount to be added
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> addMilliseconds(final int amount) {
        return new Add(Calendar.MILLISECOND, amount);
    }

    
    /**
     * <p>
     * Modifies a Calendar by adding a positive or negative amount to one the
     * "minute" property (<tt>java.util.Calendar.MINUTE</tt>). 
     * </p>
     * 
     * @param amount the positive or negative amount to be added
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> addMinutes(final int amount) {
        return new Add(Calendar.MINUTE, amount);
    }

    
    /**
     * <p>
     * Modifies a Calendar by adding a positive or negative amount to one the
     * "month" property (<tt>java.util.Calendar.MONTH</tt>). 
     * </p>
     * 
     * @param amount the positive or negative amount to be added
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> addMonths(final int amount) {
        return new Add(Calendar.MONTH, amount);
    }

    
    /**
     * <p>
     * Modifies a Calendar by adding a positive or negative amount to one the
     * "week" property (<tt>java.util.Calendar.WEEK_OF_YEAR</tt>). 
     * </p>
     * 
     * @param amount the positive or negative amount to be added
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> addWeeks(final int amount) {
        return new Add(Calendar.WEEK_OF_YEAR, amount);
    }

    
    /**
     * <p>
     * Modifies a Calendar by adding a positive or negative amount to one the
     * "year" property (<tt>java.util.Calendar.YEAR</tt>). 
     * </p>
     * 
     * @param amount the positive or negative amount to be added
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> addYears(final int amount) {
        return new Add(Calendar.YEAR, amount);
    }

    
    /**
     * <p>
     * Modifies a Calendar by setting one of its to the specified value. 
     * </p>
     * <p>
     * Fields are specified by means of <tt>java.util.Calendar</tt> constants, like
     * <tt>FnCalendar.set(Calendar.DAY_OF_MONTH, 12)</tt>.
     * </p>
     * 
     * @param calendarField the field that will be modified (java.util.Calendar constant).
     * @param value the new value
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> set(final int calendarField, final int value) {
        return new Set(calendarField, value);
    }
    
    
    /**
     * <p>
     * Modifies a Calendar by setting the "day" property (<tt>java.util.Calendar.DATE</tt>)
     * to the specified value. 
     * </p>
     * 
     * @param value the new value for the property
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> setDay(final int value) {
        return new Set(Calendar.DATE, value);
    }

    
    /**
     * <p>
     * Modifies a Calendar by setting the "hour" property (<tt>java.util.Calendar.HOUR</tt>)
     * to the specified value. 
     * </p>
     * 
     * @param value the new value for the property
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> setHour(final int value) {
        return new Set(Calendar.HOUR, value);
    }

    
    /**
     * <p>
     * Modifies a Calendar by setting the "millisecond" property (<tt>java.util.Calendar.MILLISECOND</tt>)
     * to the specified value. 
     * </p>
     * 
     * @param value the new value for the property
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> setMillisecond(final int value) {
        return new Set(Calendar.MILLISECOND, value);
    }

    
    /**
     * <p>
     * Modifies a Calendar by setting the "minute" property (<tt>java.util.Calendar.MINUTE</tt>)
     * to the specified value. 
     * </p>
     * 
     * @param value the new value for the property
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> setMinute(final int value) {
        return new Set(Calendar.MINUTE, value);
    }

    
    /**
     * <p>
     * Modifies a Calendar by setting the "month" property (<tt>java.util.Calendar.MONTH</tt>)
     * to the specified value. 
     * </p>
     * 
     * @param value the new value for the property
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> setMonth(final int value) {
        return new Set(Calendar.MONTH, value);
    }

    
    /**
     * <p>
     * Modifies a Calendar by setting the "week" property (<tt>java.util.Calendar.WEEK_OF_YEAR</tt>)
     * to the specified value. 
     * </p>
     * 
     * @param value the new value for the property
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> setWeek(final int value) {
        return new Set(Calendar.WEEK_OF_YEAR, value);
    }

    
    /**
     * <p>
     * Modifies a Calendar by setting the "year" property (<tt>java.util.Calendar.YEAR</tt>)
     * to the specified value. 
     * </p>
     * 
     * @param value the new value for the property
     * @return the modified Calendar
     */
    public static final Function<Calendar,Calendar> setYear(final int value) {
        return new Set(Calendar.YEAR, value);
    }

    
    public static final Function<Calendar,Calendar> round(final int calendarField) {
        return new Round(calendarField);
    }

    public static final Function<Calendar,Calendar> truncate(final int calendarField) {
        return new Truncate(calendarField);
    }

    public static final Function<Calendar,Boolean> before(final Calendar calendar) {
        return new Before(calendar);
    }

    public static final Function<Calendar,Boolean> after(final Calendar calendar) {
        return new After(calendar);
    }
    
    
    
    public static final Function<Calendar,String> toStr(final String pattern) {
        return new ToString(pattern);
    }
    
{'fraction_non_alphanumeric': 0.11387163561076605, 'fraction_numerical': 0.0019368196086288652, 'mean_word_length': 2.9824468085106384, 'pattern_counts': {'":': 0, '<': 135, '<?xml version=': 0, '>': 135, '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': '364457', 'n_tokens_mistral': 4275, 'n_tokens_neox': 4091, 'n_words': 1305}