    001    /*
    002     * Copyright (c) 2007-2014 Concurrent, Inc. All Rights Reserved.
    003     *
    004     * Project and contact information: http://www.cascading.org/
    005     *
    006     * This file is part of the Cascading project.
    007     *
    008     * Licensed under the Apache License, Version 2.0 (the "License");
    009     * you may not use this file except in compliance with the License.
    010     * You may obtain a copy of the License at
    011     *
    012     *     http://www.apache.org/licenses/LICENSE-2.0
    013     *
    014     * Unless required by applicable law or agreed to in writing, software
    015     * distributed under the License is distributed on an "AS IS" BASIS,
    016     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    017     * See the License for the specific language governing permissions and
    018     * limitations under the License.
    019     */
    020
    021    package cascading.operation.aggregator;
    022
    023    import java.beans.ConstructorProperties;
    024
    025    import cascading.tuple.Fields;
    026
    027    /**
    028     * Class Min is an {@link cascading.operation.Aggregator} that returns the minimum value encountered in the current group.
    029     * <p/>
    030     * As opposed to the {@link Min} class, values are expected to be {@link Comparable} types vs numeric representations and
    031     * the {@link Comparable#compareTo(Object)} result is use for min comparison.
    032     */
    033    public class MinValue extends ExtremaValueBase
    034      {
    035      /** Field FIELD_NAME */
    036      public static final String FIELD_NAME = "min";
    037
    038      /** Constructs a new instance that returns the Min value encountered in the field name "min". */
    039      public MinValue()
    040        {
    041        super( 1, new Fields( FIELD_NAME ) );
    042        }
    043
    044      /**
    045       * Constructs a new instance that returns the minimum value encountered in the given fieldDeclaration field name.
    046       *
    047       * @param fieldDeclaration of type Fields
    048       */
    049      @ConstructorProperties({"fieldDeclaration"})
    050      public MinValue( Fields fieldDeclaration )
    051        {
    052        super( 1, fieldDeclaration );
    053        }
    054
    055      /**
    056       * Constructs a new instance that returns the minimum value encountered in the given fieldDeclaration field name.
    057       * Any argument matching an ignoredValue won't be compared.
    058       *
    059       * @param fieldDeclaration of type Fields
    060       * @param ignoreValues     of type Object...
    061       */
    062      @ConstructorProperties({"fieldDeclaration", "ignoreValues"})
    063      public MinValue( Fields fieldDeclaration, Object... ignoreValues )
    064        {
    065        super( fieldDeclaration, ignoreValues );
    066        }
    067
    068      @Override
    069      protected boolean compare( Comparable lhs, Comparable rhs )
    070        {
    071        return lhs.compareTo( rhs ) > 0;
    072        }
    073      }