Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [riena-dev] IDisposable ...

Stefan,

just one thing: I think having a static class within the interface is
highly unusual. I would rather move it into a separate class.

Kind regards,
Elias.

On Wed, Jul 28, 2010 at 12:34 AM, Liebig, Stefan
<Stefan.Liebig@xxxxxxxxxxxx> wrote:
> Hi Rienars,
>
>
>
> Sorry, another stumble.
>
>
>
> While looking at SwtUtilities I wondered why there is no
> dispose()/isDisposed() helper for IDisposables.
>
> Maybe because SwtUtilities (ui.swt) is "too far away" from IDisposable
> (ui.core). Ok!
>
>
>
> But I would like to have something similar. Introducing a new helper just
> for dispose in ui.core? Maybe!?
>
>
>
> But, how about this:
>
>
>
> public interface IDisposable {
>
>
>
>       /**
>
>        * Disposes this object, i.e. free any resources.
>
>        */
>
>       void dispose();
>
>
>
>       /**
>
>        * Check whether this object has already disposed or not.
>
>        *
>
>        * @return disposed or not
>
>        */
>
>       boolean isDisposed();
>
>
>
>       /**
>
>        * Provides a helper on {@code IDisposable}s.
>
>        */
>
>       public static final class Util {
>
>
>
>             private Util() {
>
>                   // utility
>
>             }
>
>
>
>             /**
>
>              * Disposes the given {@code IDisposable}, if the {@code
> IDisposable} is
>
>              * not {@code null} and is not already disposed.
>
>              *
>
>              * @param disposable
>
>              *            {@code IDisposable} to dispose
>
>              */
>
>             public static void dispose(final IDisposable disposable) {
>
>                   if (disposable != null && !disposable.isDisposed()) {
>
>                         disposable.dispose();
>
>                   }
>
>             }
>
>
>
>       }
>
> }
>
>
>
> Can be used like this:
>
>
>
>       IDisposable.Util.dispose(getNavigationNode());
>
>
>
> Yep, requires getting used to it!
>
>
>
> Thoughts and feedback?
>
>
>
> Tschüß,
>
> Stefan
>
>
>
> -------------------------------------------------------------
> compeople AG
> Untermainanlage 8
> 60329 Frankfurt/Main
> fon: +49 (0) 69 / 27 22 18 0
> fax: +49 (0) 69 / 27 22 18 22
> web: www.compeople.de
>
> Vorstand: Jürgen Wiesmaier
> Aufsichtsratsvorsitzender: Christian Glanz
>
> Sitz der Gesellschaft: Frankfurt/Main
> Handelsregister Frankfurt HRB 56759
> Ust-Ident.-Nr: DE207665352
> -------------------------------------------------------------
>
> _______________________________________________
> riena-dev mailing list
> riena-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/riena-dev
>
>



-- 
Elias Volanakis | Technical Lead | http://eclipsesource.com
elias@xxxxxxxxxxxxxxxxx | +1 503 929 5537 | @evolanakis


Back to the top