001    /*
002     * Created on May 21, 2007
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005     * in compliance with the License. You may obtain a copy of the License at
006     *
007     * http://www.apache.org/licenses/LICENSE-2.0
008     *
009     * Unless required by applicable law or agreed to in writing, software distributed under the License
010     * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011     * or implied. See the License for the specific language governing permissions and limitations under
012     * the License.
013     *
014     * Copyright @2007-2009 the original author or authors.
015     */
016    package org.fest.assertions;
017    
018    /**
019     * Understands a template for assertion methods related to arrays or collections.
020     * @param <T> the type of object implementations of this template can verify.
021     *
022     * @author Yvonne Wang
023     * @author Alex Ruiz
024     */
025    public abstract class GroupAssert<T> extends GenericAssert<T> {
026    
027      /**
028       * Creates a new <code>{@link GroupAssert}</code>.
029       * @param actual the target to verify.
030       */
031      protected GroupAssert(T actual) {
032        super(actual);
033      }
034    
035      /**
036       * Verifies that the actual group is <code>null</code> or empty.
037       * @throws AssertionError if the actual group is not <code>null</code> or not empty.
038       */
039      protected abstract void isNullOrEmpty();
040    
041      /**
042       * Verifies that the actual group is empty.
043       * @throws AssertionError if the actual group is <code>null</code> or not empty.
044       */
045      protected abstract void isEmpty();
046    
047      /**
048       * Verifies that the actual group contains at least on value.
049       * @return this assertion object.
050       * @throws AssertionError if the actual group is <code>null</code> or empty.
051       */
052      protected abstract GroupAssert<T> isNotEmpty();
053    
054      /**
055       * Verifies that the number of values in the actual group is equal to the given one.
056       * @param expected the expected number of values in the actual group.
057       * @return this assertion object.
058       * @throws AssertionError if the number of values of the actual group is not equal to the given one.
059       */
060      protected abstract GroupAssert<T> hasSize(int expected);
061    
062      /**
063       * Returns the size of the actual group (array, collection, etc.)
064       * @return the size of the actual group.
065       */
066      protected abstract int actualGroupSize();
067    }