public static < T extends Tag < ? > > T checkTagCast ( Tag < ? > tag , Class < T > type ) throws IllegalArgumentException { if ( tag == null ) { throw new IllegalArgumentException ( "Expected tag of type " + type . getName ( ) + ", was null" ) ; } else if ( ! type . isInstance ( tag ) ) { throw new IllegalArgumentException ( "Expected tag to be a " + type . getName ( ) + ", was a " + tag . getClass ( ) . getName ( ) ) ; } return type . cast ( tag ) ; }
Checks that a tag is not null and of the required type