001 /*
002 * Created on Feb 16, 2008
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
005 * 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 is distributed on
010 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
011 * specific language governing permissions and limitations under the License.
012 *
013 * Copyright @2008-2011 the original author or authors.
014 */
015 package org.fest.assertions;
016
017 import static org.fest.assertions.ArrayInspection.*;
018
019 import java.util.List;
020 import java.util.Set;
021
022 /**
023 * Assertions for arrays.
024 * @param <S> used to simulate "self types." For more information please read "<a
025 * href="http://passion.forco.de/content/emulating-self-types-using-java-generics-simplify-fluent-api-implementation"
026 * target="_blank">Emulating 'self types' using Java Generics to simplify fluent API implementation</a>."
027 * @param <A> the type the "actual" value.
028 *
029 * @author Alex Ruiz
030 */
031 public abstract class ArrayAssert<S, A> extends ItemGroupAssert<S, A> {
032
033 /**
034 * Creates a new </code>{@link ArrayAssert}</code>.
035 * @param selfType the "self type."
036 * @param actual the target to verify.
037 */
038 protected ArrayAssert(Class<S> selfType, A actual) {
039 super(selfType, actual);
040 }
041
042 /**
043 * Returns the size of the actual array.
044 * @return the size of the actual array.
045 * @throws NullPointerException if the actual array is {@code null}.
046 */
047 @Override protected final int actualGroupSize() {
048 isNotNull();
049 return sizeOf(actual);
050 }
051
052 /** {@inheritDoc} */
053 @Override protected Set<Object> actualAsSet() {
054 return toSet(actual);
055 }
056
057 /** {@inheritDoc} */
058 @Override protected List<Object> actualAsList() {
059 return toList(actual);
060 }
061 }