diff options
author | Julien Gouesse <[email protected]> | 2023-02-16 00:20:12 +0100 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2023-02-16 00:20:12 +0100 |
commit | 71a86a847cee5c45d968579be804ba4ee5d928f8 (patch) | |
tree | a1c2d8b35b641ec84d0d5d35e7f6092ef2a25cf7 | |
parent | aa6df077361bf1470d3799514f5774951025bed4 (diff) |
Clarifies some types in ardor3d-audio
5 files changed, 32 insertions, 60 deletions
diff --git a/ardor3d-audio/src/main/java/com/ardor3d/audio/Channel.java b/ardor3d-audio/src/main/java/com/ardor3d/audio/Channel.java index 4906809..4e196b0 100644 --- a/ardor3d-audio/src/main/java/com/ardor3d/audio/Channel.java +++ b/ardor3d-audio/src/main/java/com/ardor3d/audio/Channel.java @@ -57,7 +57,7 @@ public class Channel /** * The library class associated with this type of channel. */ - protected Class libraryType = Library.class; + protected Class<? extends Library> libraryType = Library.class; /** * Global identifier for the type of channel (normal or streaming). Possible diff --git a/ardor3d-audio/src/main/java/com/ardor3d/audio/CommandObject.java b/ardor3d-audio/src/main/java/com/ardor3d/audio/CommandObject.java index 0b3dbed..84e82c3 100644 --- a/ardor3d-audio/src/main/java/com/ardor3d/audio/CommandObject.java +++ b/ardor3d-audio/src/main/java/com/ardor3d/audio/CommandObject.java @@ -277,7 +277,7 @@ public class CommandObject * @param cmd Which command to execute. * @param c The Library Class argument needed to execute this command. */ - public CommandObject( int cmd, Class c ) + public CommandObject( int cmd, Class<? extends Library> c ) { Command = cmd; classArgs = new Class[1]; diff --git a/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystem.java b/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystem.java index 671fd5d..a30f05d 100644 --- a/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystem.java +++ b/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystem.java @@ -129,7 +129,7 @@ public class SoundSystem /** * Indicates the currently loaded sound-library, or null if none. */ - private static Class currentLibrary = null; + private static Class<? extends Library> currentLibrary = null; /** * Becomes true when the sound library has been initialized. @@ -161,12 +161,12 @@ public class SoundSystem linkDefaultLibrariesAndCodecs(); - LinkedList<Class> libraries = SoundSystemConfig.getLibraries(); + LinkedList<Class<? extends Library>> libraries = SoundSystemConfig.getLibraries(); if( libraries != null ) { - ListIterator<Class> i = libraries.listIterator(); - Class c; + ListIterator<Class<? extends Library>> i = libraries.listIterator(); + Class<? extends Library> c; while( i.hasNext() ) { c = i.next(); @@ -198,7 +198,7 @@ public class SoundSystem * See {@link com.ardor3d.audio.SoundSystemConfig SoundSystemConfig} for * information about chosing a sound library. */ - public SoundSystem( Class libraryClass ) throws SoundSystemException + public SoundSystem( Class<? extends Library> libraryClass ) throws SoundSystemException { // create the message logger: logger = SoundSystemConfig.getLogger(); @@ -232,7 +232,7 @@ public class SoundSystem * See {@link com.ardor3d.audio.SoundSystemConfig SoundSystemConfig} for * information about chosing a sound library. */ - protected void init( Class libraryClass ) throws SoundSystemException + protected void init( Class<? extends Library> libraryClass ) throws SoundSystemException { message( "", 0 ); message( "Starting up " + className + "...", 0 ); @@ -1370,7 +1370,7 @@ public class SoundSystem * See {@link com.ardor3d.audio.SoundSystemConfig SoundSystemConfig} for * information about chosing a sound library. */ - public boolean switchLibrary( Class libraryClass ) + public boolean switchLibrary( Class<? extends Library> libraryClass ) throws SoundSystemException { synchronized( SoundSystemConfig.THREAD_SYNC ) @@ -1397,7 +1397,7 @@ public class SoundSystem try { - soundLibrary = (Library) libraryClass.getDeclaredConstructor().newInstance(); + soundLibrary = libraryClass.getDeclaredConstructor().newInstance(); } catch( NoSuchMethodException nsme ) { @@ -1465,7 +1465,7 @@ public class SoundSystem * See {@link com.ardor3d.audio.SoundSystemConfig SoundSystemConfig} for * information about chosing a sound library. */ - public boolean newLibrary( Class libraryClass ) + public boolean newLibrary( Class<? extends Library> libraryClass ) throws SoundSystemException { initialized( SET, false ); @@ -1506,7 +1506,7 @@ public class SoundSystem * See {@link com.ardor3d.audio.SoundSystemConfig SoundSystemConfig} for * information about chosing a sound library. */ - private void CommandNewLibrary( Class libraryClass ) + private void CommandNewLibrary( Class<? extends Library> libraryClass ) { initialized( SET, false ); @@ -1526,7 +1526,7 @@ public class SoundSystem try { - soundLibrary = (Library) libraryClass.getDeclaredConstructor().newInstance(); + soundLibrary = libraryClass.getDeclaredConstructor().newInstance(); } catch( Exception e ) { @@ -2712,7 +2712,7 @@ public class SoundSystem * @param libraryClass Libary type to check. * @return True or false. */ - public static boolean libraryCompatible( Class libraryClass ) + public static boolean libraryCompatible( Class<? extends Library> libraryClass ) { // create the message logger: SoundSystemLogger logger = SoundSystemConfig.getLogger(); @@ -2741,7 +2741,7 @@ public class SoundSystem * Returns the currently loaded library, or -1 if none. * @return Global library identifier */ - public static Class currentLibrary() + public static Class<? extends Library> currentLibrary() { return( currentLibrary( GET, null ) ); } @@ -2796,8 +2796,8 @@ public class SoundSystem * @param value New value if action is SET, otherwise XXX. * @return value of boolean 'initialized'. */ - private static Class currentLibrary( boolean action, - Class value ) + private static Class<? extends Library> currentLibrary( boolean action, + Class<? extends Library> value ) { synchronized( SoundSystemConfig.THREAD_SYNC ) { diff --git a/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystemConfig.java b/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystemConfig.java index 59b16c0..65bdf2a 100644 --- a/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystemConfig.java +++ b/ardor3d-audio/src/main/java/com/ardor3d/audio/SoundSystemConfig.java @@ -123,7 +123,7 @@ public class SoundSystemConfig /** * List of library types in their order of priority. */ - private static LinkedList<Class> libraries; + private static LinkedList<Class<? extends Library>> libraries; /** * List of codecs and the file formats they are associated with. @@ -234,7 +234,7 @@ public class SoundSystemConfig * load libraries in the order that they were entered into the list. * @param libraryClass Derivitive of class 'Library'. */ - public static void addLibrary( Class libraryClass ) + public static void addLibrary( Class<? extends Library> libraryClass ) throws SoundSystemException { if( libraryClass == null ) @@ -246,7 +246,7 @@ public class SoundSystemConfig "extend class 'Library' in method 'addLibrary'" ); if( libraries == null ) - libraries = new LinkedList<Class>(); + libraries = new LinkedList<Class<? extends Library>>(); if( !libraries.contains( libraryClass ) ) libraries.add( libraryClass ); @@ -256,7 +256,7 @@ public class SoundSystemConfig * Removes the specified library from the list of library types. * @param libraryClass Derivitive of class 'Library'. */ - public static void removeLibrary( Class libraryClass ) + public static void removeLibrary( Class<? extends Library> libraryClass ) throws SoundSystemException { if( libraries == null || libraryClass == null ) @@ -269,7 +269,7 @@ public class SoundSystemConfig * Returns the list of library types. * @return LinkedList of classes derived from 'Library', or null if none were specified. */ - public static LinkedList<Class> getLibraries() + public static LinkedList<Class<? extends Library>> getLibraries() { return libraries; } @@ -279,7 +279,7 @@ public class SoundSystemConfig * @param libraryClass Library type to check. * @return True or false. */ - public static boolean libraryCompatible( Class libraryClass ) + public static boolean libraryCompatible( Class<? extends Library> libraryClass ) { if( libraryClass == null ) { @@ -287,12 +287,6 @@ public class SoundSystemConfig "'librayCompatible'" ); return false; } - if( !Library.class.isAssignableFrom( libraryClass ) ) - { - errorMessage( "The specified class does not extend class " + - "'Library' in method 'libraryCompatible'" ); - return false; - } Object o = runMethod( libraryClass, "libraryCompatible", new Class[0], new Object[0] ); @@ -312,7 +306,7 @@ public class SoundSystemConfig * @param libraryClass Derivitive of class 'Library'. * @return String containing the library title. */ - public static String getLibraryTitle( Class libraryClass ) + public static String getLibraryTitle( Class<? extends Library> libraryClass ) { if( libraryClass == null ) { @@ -320,13 +314,7 @@ public class SoundSystemConfig "'getLibrayTitle'" ); return null; } - if( !Library.class.isAssignableFrom( libraryClass ) ) - { - errorMessage( "The specified class does not extend class " + - "'Library' in method 'getLibraryTitle'" ); - return null; - } - + Object o = runMethod( libraryClass, "getTitle", new Class[0], new Object[0] ); if( o == null ) @@ -344,7 +332,7 @@ public class SoundSystemConfig * @param libraryClass Derivitive of class 'Library'. * @return String containing the library title. */ - public static String getLibraryDescription( Class libraryClass ) + public static String getLibraryDescription( Class<? extends Library> libraryClass ) { if( libraryClass == null ) { @@ -352,12 +340,6 @@ public class SoundSystemConfig "'getLibrayDescription'" ); return null; } - if( !Library.class.isAssignableFrom( libraryClass ) ) - { - errorMessage( "The specified class does not extend class " + - "'Library' in method 'getLibraryDescription'" ); - return null; - } Object o = runMethod( libraryClass, "getDescription", new Class[0], new Object[0] ); @@ -376,7 +358,7 @@ public class SoundSystemConfig * @param libraryClass Derivitive of class 'Library'. * @return True if byte-order reversal is required. */ - public static boolean reverseByteOrder( Class libraryClass ) + public static boolean reverseByteOrder( Class<? extends Library> libraryClass ) { if( libraryClass == null ) { @@ -384,12 +366,6 @@ public class SoundSystemConfig "'reverseByteOrder'" ); return false; } - if( !Library.class.isAssignableFrom( libraryClass ) ) - { - errorMessage( "The specified class does not extend class " + - "'Library' in method 'reverseByteOrder'" ); - return false; - } Object o = runMethod( libraryClass, "reversByteOrder", new Class[0], new Object[0] ); @@ -730,7 +706,7 @@ public class SoundSystemConfig * @param iCodecClass Codec type to use for files with the specified extension. */ public static synchronized void setCodec( String extension, - Class iCodecClass ) + Class<? extends ICodec> iCodecClass ) throws SoundSystemException { if( extension == null ) @@ -741,10 +717,6 @@ public class SoundSystemConfig throw new SoundSystemException( "Parameter 'iCodecClass' null in " + "method 'setCodec'.", SoundSystemException.NULL_PARAMETER ); - if( !ICodec.class.isAssignableFrom( iCodecClass ) ) - throw new SoundSystemException( "The specified class does " + - "not implement interface 'ICodec' in method 'setCodec'", - SoundSystemException.CLASS_TYPE_MISMATCH ); if( codecs == null ) codecs = new LinkedList<Codec>(); @@ -900,7 +872,7 @@ public class SoundSystemConfig * @param params Actual parameters to pass to the method. * @return Specified method's return value, or null if error or void. */ - private static Object runMethod( Class c, String method, Class[] paramTypes, + private static Object runMethod( Class<?> c, String method, Class[] paramTypes, Object[] params ) { Method m = null; @@ -1000,14 +972,14 @@ public class SoundSystemConfig /** * Codec used to load audio data from this file format. */ - public Class iCodecClass; + public Class<? extends ICodec> iCodecClass; /** * Constructor: Converts the specified extension string into a regular * expression, and associates that with the specified codec. * @param extension File extension to be associated with the specified codec. * @param iCodec Codec to use for files with the specified extension. */ - public Codec( String extension, Class iCodecClass ) + public Codec( String extension, Class<? extends ICodec> iCodecClass ) { extensionRegX = ""; // Make sure an extension was specified: diff --git a/ardor3d-audio/src/main/java/com/ardor3d/audio/Source.java b/ardor3d-audio/src/main/java/com/ardor3d/audio/Source.java index bd96fdb..38af692 100644 --- a/ardor3d-audio/src/main/java/com/ardor3d/audio/Source.java +++ b/ardor3d-audio/src/main/java/com/ardor3d/audio/Source.java @@ -60,7 +60,7 @@ public class Source /** * The library class associated with this type of channel. */ - protected Class libraryType = Library.class; + protected Class<? extends Library> libraryType = Library.class; /** * Used to return a current value from one of the synchronized |