| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Casting | 
  | 
  | 0.0;0 | 
| 1 |  /* | |
| 2 |   Copyright 2004-2008 Paul R. Holser, Jr.  All rights reserved. | |
| 3 |   Licensed under the Academic Free License version 3.0 | |
| 4 |   */ | |
| 5 | ||
| 6 |  package jaggregate.internal; | |
| 7 | ||
| 8 | import static jaggregate.internal.CompilerWarnings.*;  | |
| 9 | ||
| 10 |  /** | |
| 11 |   * Facilities used internally for casting. | |
| 12 |   * | |
| 13 |   * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> | |
| 14 |   * @version $Id: Casting.java,v 1.2 2008/03/30 03:07:11 pholser Exp $ | |
| 15 |   */ | |
| 16 | public class Casting {  | |
| 17 |      /** | |
| 18 |       * Discourages instantiation. | |
| 19 |       * | |
| 20 |       * @throws UnsupportedOperationException always | |
| 21 |       */ | |
| 22 | 1 |      protected Casting() { | 
| 23 | 1 | throw new UnsupportedOperationException();  | 
| 24 | }  | |
| 25 | ||
| 26 |      /** | |
| 27 |       * Performs an unchecked cast of a given object to a given type. | |
| 28 |       * <p/> | |
| 29 |       * This method helps to eliminate compiler warnings from within Jaggregate code in | |
| 30 |       * areas where "unsafe" casts are known to be safe yet cannot be suppressed easily, | |
| 31 |       * at all, or without annotating at too broad of a scope or too frequently via | |
| 32 |       * {@link SuppressWarnings}.  <em>Be careful</em>--don't use this method to try to | |
| 33 |       * dodge responsibility for type-safe code. | |
| 34 |       * | |
| 35 |       * @see Class#cast(Object) | |
| 36 |       * @param <T> a restriction on the type of the new reference to the object | |
| 37 |       * @param item the object to cast | |
| 38 |       * @return a reference to {@code item}, of a different type | |
| 39 |       * @throws ClassCastException if the cast fails; that is, {@code item} cannot be | |
| 40 |       * referenced by a variable of the chosen or inferred type | |
| 41 |       */ | |
| 42 | @SuppressWarnings( UNCHECKED )  | |
| 43 | public static <T> T cast( Object item ) {  | |
| 44 | 115407 |          return (T) item; | 
| 45 | }  | |
| 46 | }  |