diff options
author | Sven Gothel <[email protected]> | 2013-10-17 17:25:38 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-10-17 17:25:38 +0200 |
commit | 202834f148e0eb8c435af02850085d582b3006a4 (patch) | |
tree | 88a79d0c93f7a3d6d49c0da208de1e72a85f0722 /src/jogl/classes | |
parent | c9837ef133ff3465d9b06f1907a7a320181ec97c (diff) |
Refine Int -> Enum conversion (commit 40863632d1428de015099b5967e5136425e99f25), throw IllegalArgumentException if ordinal is out-of-range. Add API doc.
- FFMPEGNatives
- MouseEvent.PointerType
Diffstat (limited to 'src/jogl/classes')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java index 89c15b905..8e08c23fa 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java @@ -92,13 +92,22 @@ interface FFMPEGNatives { COUNT; ///< Number of sample formats. - public static SampleFormat valueOf(int i) { - // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal] + /** + * Returns the matching SampleFormat value corresponding to the given SampleFormat's integer ordinal. + * <pre> + * given: + * ordinal = enumValue.ordinal() + * reverse: + * enumValue = EnumClass.values()[ordinal] + * </pre> + * @throws IllegalArgumentException if the given ordinal is out of range, i.e. not within [ 0 .. SampleFormat.values().length-1 ] + */ + public static SampleFormat valueOf(int ordinal) throws IllegalArgumentException { final SampleFormat[] all = SampleFormat.values(); - if( 0 <= i && i < all.length ) { - return all[i]; + if( 0 <= ordinal && ordinal < all.length ) { + return all[ordinal]; } - return null; + throw new IllegalArgumentException("Ordinal "+ordinal+" out of range of SampleFormat.values()[0.."+(all.length-1)+"]"); } }; @@ -246,13 +255,22 @@ interface FFMPEGNatives { GBRP16LE, ///< planar GBR 4:4:4 48bpp, little endian COUNT ///< number of pixel formats in this list ; - public static PixelFormat valueOf(int i) { - // ordinal = enumValue.ordinal(), reverse: enumValue = EnumClass.values()[ordinal] + /** + * Returns the matching PixelFormat value corresponding to the given PixelFormat's integer ordinal. + * <pre> + * given: + * ordinal = enumValue.ordinal() + * reverse: + * enumValue = EnumClass.values()[ordinal] + * </pre> + * @throws IllegalArgumentException if the given ordinal is out of range, i.e. not within [ 0 .. PixelFormat.values().length-1 ] + */ + public static PixelFormat valueOf(int ordinal) throws IllegalArgumentException { final PixelFormat[] all = PixelFormat.values(); - if( 0 <= i && i < all.length ) { - return all[i]; + if( 0 <= ordinal && ordinal < all.length ) { + return all[ordinal]; } - return null; + throw new IllegalArgumentException("Ordinal "+ordinal+" out of range of PixelFormat.values()[0.."+(all.length-1)+"]"); } } -} +}
\ No newline at end of file |