@@ -56,21 +56,46 @@ public interface IOPlugin<D> extends HandlerPlugin<String> {
5656 Class <D > getDataType ();
5757
5858 /** Checks whether the I/O plugin can open data from the given source. */
59- boolean supportsOpen (String source );
59+ @ SuppressWarnings ("unused" )
60+ default boolean supportsOpen (final String source ) {
61+ return false ;
62+ }
6063
6164 /** Checks whether the I/O plugin can save data to the given destination. */
62- boolean supportsSave (String destination );
65+ @ SuppressWarnings ("unused" )
66+ default boolean supportsSave (final String destination ) {
67+ return false ;
68+ }
6369
6470 /**
6571 * Checks whether the I/O plugin can save the given data to the specified
6672 * destination.
6773 */
68- boolean supportsSave (Object data , String destination );
74+ default boolean supportsSave (final Object data , final String destination ) {
75+ return supportsSave (destination ) && getDataType ().isInstance (data );
76+ }
6977
7078 /** Opens data from the given source. */
71- D open (String source ) throws IOException ;
79+ @ SuppressWarnings ("unused" )
80+ default D open (final String source ) throws IOException {
81+ throw new UnsupportedOperationException ();
82+ }
7283
7384 /** Saves the given data to the specified destination. */
74- void save (D data , String destination ) throws IOException ;
85+ @ SuppressWarnings ("unused" )
86+ default void save (final D data , final String destination ) throws IOException {
87+ throw new UnsupportedOperationException ();
88+ }
7589
90+ // -- Typed methods --
91+
92+ @ Override
93+ default boolean supports (final String descriptor ) {
94+ return supportsOpen (descriptor ) || supportsSave (descriptor );
95+ }
96+
97+ @ Override
98+ default Class <String > getType () {
99+ return String .class ;
100+ }
76101}
0 commit comments