// Path: src/main/java/org/fest/util/Preconditions.java
// public static @NotNull <T> T checkNotNull(@Nullable T reference) {
//   if (reference == null) {
//     throw new NullPointerException();
//   }
//   return reference;
// }


import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static org.fest.util.Preconditions.checkNotNull;
/*
 * Created on Nov 1, 2007
 * 
 * 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.
 * 
 * Copyright @2007-2011 the original author or authors.
 */
package org.fest.util;



/**
 * Filters elements of a collection by their data type.
 *
 * @param <T> the generic type of the objects returned by the filter.
 * @author Yvonne Wang
 */
public class TypeFilter<T> implements CollectionFilter<T> {
  private final Class<T> type;

  TypeFilter(Class<T> type) {
    this.type = type;
  }

  /**
   * Creates a new {@link TypeFilter}.
   *
   * @param <T>  the generic type of the target type.
   * @param type the target type for this filter.
   * @return the created filter.
   */
  public static @NotNull <T> TypeFilter<T> byType(@NotNull Class<T> type) {
    return new TypeFilter<T>(type);
  }

  /**
   * Filters the given collection by the type specified in this filter.
   *
   * @param target the collection to filter.
   * @return a list containing the filtered elements.
   * @throws NullPointerException if the given collection is {@code null}.
   */
  @Override
  @SuppressWarnings("unchecked")
  public @NotNull List<T> filter(@NotNull Collection<?> target) {
// Path: src/main/java/org/fest/util/Preconditions.java
// public static @NotNull <T> T checkNotNull(@Nullable T reference) {
//   if (reference == null) {
//     throw new NullPointerException();
//   }
//   return reference;
// }


// Path: src/main/java/org/fest/util/TypeFilter.java
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static org.fest.util.Preconditions.checkNotNull;

/*
 * Created on Nov 1, 2007
 * 
 * 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.
 * 
 * Copyright @2007-2011 the original author or authors.
 */
package org.fest.util;



/**
 * Filters elements of a collection by their data type.
 *
 * @param <T> the generic type of the objects returned by the filter.
 * @author Yvonne Wang
 */
public class TypeFilter<T> implements CollectionFilter<T> {
  private final Class<T> type;

  TypeFilter(Class<T> type) {
    this.type = type;
  }

  /**
   * Creates a new {@link TypeFilter}.
   *
   * @param <T>  the generic type of the target type.
   * @param type the target type for this filter.
   * @return the created filter.
   */
  public static @NotNull <T> TypeFilter<T> byType(@NotNull Class<T> type) {
    return new TypeFilter<T>(type);
  }

  /**
   * Filters the given collection by the type specified in this filter.
   *
   * @param target the collection to filter.
   * @return a list containing the filtered elements.
   * @throws NullPointerException if the given collection is {@code null}.
   */
  @Override
  @SuppressWarnings("unchecked")
  public @NotNull List<T> filter(@NotNull Collection<?> target) {
    checkNotNull(target);