|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ComponentFixtureValidator | Line # 27 | 6 | 7.7% | 4 | 0 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| No Tests | |||
| 1 | /* | |
| 2 | * Created on Jul 8, 2008 | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | |
| 5 | * in compliance with the License. You may obtain a copy of the License at | |
| 6 | * | |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 | * | |
| 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License | |
| 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
| 11 | * or implied. See the License for the specific language governing permissions and limitations under | |
| 12 | * the License. | |
| 13 | * | |
| 14 | * Copyright @2008-2010 the original author or authors. | |
| 15 | */ | |
| 16 | package org.fest.swing.fixture; | |
| 17 | ||
| 18 | import java.awt.Component; | |
| 19 | ||
| 20 | import org.fest.swing.core.Robot; | |
| 21 | ||
| 22 | /** | |
| 23 | * Understands a validator of common objects used in component fixtures. | |
| 24 | * | |
| 25 | * @author Alex Ruiz | |
| 26 | */ | |
| 27 | public final class ComponentFixtureValidator { | |
| 28 | ||
| 29 | /** | |
| 30 | * Verifies that the given <code>{@link Robot}</code> is not <code>null</code>. | |
| 31 | * @param robot the <code>Robot</code> to verify. | |
| 32 | * @return the given <code>Robot</code>. | |
| 33 | * @throws NullPointerException if <code>robot</code> is <code>null</code>. | |
| 34 | */ | |
| 35 | 1491 |
public static Robot notNullRobot(Robot robot) { |
| 36 | 5 | if (robot == null) throw new NullPointerException("Robot should not be null"); |
| 37 | 1486 | return robot; |
| 38 | } | |
| 39 | ||
| 40 | /** | |
| 41 | * Verifies that the given <code>{@link Component}</code> is not <code>null</code>. | |
| 42 | * @param <T> specifies the type of <code>Component</code> to return. | |
| 43 | * @param target the <code>Component</code> to verify. | |
| 44 | * @return the given target <code>Component</code>. | |
| 45 | * @throws NullPointerException if <code>target</code> is <code>null</code>. | |
| 46 | */ | |
| 47 | 1400 |
public static <T extends Component> T notNullTarget(T target) { |
| 48 | 3 | if (target == null) throw new NullPointerException("Target component should not be null"); |
| 49 | 1397 | return target; |
| 50 | } | |
| 51 | ||
| 52 |
private ComponentFixtureValidator() {} |
|
| 53 | } | |
|
||||||||||||