001 /* 002 * Created on Jul 8, 2008 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 @2008-2010 the original author or authors. 015 */ 016 package org.fest.swing.fixture; 017 018 import java.awt.Component; 019 020 import org.fest.swing.core.Robot; 021 022 /** 023 * Understands a validator of common objects used in component fixtures. 024 * 025 * @author Alex Ruiz 026 */ 027 public final class ComponentFixtureValidator { 028 029 /** 030 * Verifies that the given <code>{@link Robot}</code> is not <code>null</code>. 031 * @param robot the <code>Robot</code> to verify. 032 * @return the given <code>Robot</code>. 033 * @throws NullPointerException if <code>robot</code> is <code>null</code>. 034 */ 035 public static Robot notNullRobot(Robot robot) { 036 if (robot == null) throw new NullPointerException("Robot should not be null"); 037 return robot; 038 } 039 040 /** 041 * Verifies that the given <code>{@link Component}</code> is not <code>null</code>. 042 * @param <T> specifies the type of <code>Component</code> to return. 043 * @param target the <code>Component</code> to verify. 044 * @return the given target <code>Component</code>. 045 * @throws NullPointerException if <code>target</code> is <code>null</code>. 046 */ 047 public static <T extends Component> T notNullTarget(T target) { 048 if (target == null) throw new NullPointerException("Target component should not be null"); 049 return target; 050 } 051 052 private ComponentFixtureValidator() {} 053 }