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.assertion;
022    
023    import java.beans.ConstructorProperties;
024    
025    import cascading.management.annotation.Property;
026    import cascading.management.annotation.PropertyDescription;
027    import cascading.management.annotation.Visibility;
028    
029    /**
030     * Class AssertGroupSizeEquals is an {@link cascading.operation.GroupAssertion} that asserts the number of items in the current group
031     * is more than the given size.
032     * </p>
033     * If a patternString is given, only grouping keys that match the regular expression will have this assertion applied.
034     * Note multiple key values will be delimited by a tab character.
035     */
036    public class AssertGroupSizeMoreThan extends AssertGroupBase
037      {
038    
039      /**
040       * Constructor AssertGroupSizeMoreThan creates a new AssertGroupSizeMoreThan instance.
041       *
042       * @param size of type long
043       */
044      @ConstructorProperties({"size"})
045      public AssertGroupSizeMoreThan( long size )
046        {
047        super( "group size %s, is less than or equal to: %s, in group %s: %s", size );
048        }
049    
050      /**
051       * Constructor AssertGroupSizeMoreThan creates a new AssertGroupSizeMoreThan instance.
052       *
053       * @param patternString of type String
054       * @param size          of type long
055       */
056      @ConstructorProperties({"patternString", "size"})
057      public AssertGroupSizeMoreThan( String patternString, long size )
058        {
059        super( "group matching '%s' with size: %s, is less than or equal to: %s, in group %s: %s", patternString, size );
060        }
061    
062      @Property(name = "size", visibility = Visibility.PRIVATE)
063      @PropertyDescription("The minimum group size.")
064      @Override
065      public long getSize()
066        {
067        return super.getSize();
068        }
069    
070      @Override
071      protected boolean assertFails( Long groupSize )
072        {
073        return groupSize <= size;
074        }
075      }