Sunday, June 10, 2012

Is there anything like .NET"s NotImplementedException in Java?


Is there anything like .net's NotImplementedException in java?



Source: Tips4all

3 comments:

  1. Commons Lang has it: http://commons.apache.org/lang/api-2.4/org/apache/commons/lang/NotImplementedException.html

    Or you could throw a UnsupportedOperationException - http://java.sun.com/j2se/1.4.2/docs/api/java/lang/UnsupportedOperationException.html

    ReplyDelete
  2. I think the UnsupportedOperationException is what you are looking for.

    http://java.sun.com/javase/6/docs/api/java/lang/UnsupportedOperationException.html

    ReplyDelete
  3. You could do it yourself (thats what I did) - in order to not be bothered with exception handling, you simply extend the RuntimeException, your class could look something like this:

    public class NotImplementedException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    public NotImplementedException(){}
    }


    You could extend it to take a message - but if you use the method as I do (that is, as a reminder, that there is still something to be implemented), then usually there is no need for additional messages.

    I dare say, that I only use this method, while I am in the process of developing a system, makes it easier for me to not lose track of which methods are still not implemented properly :)

    Cheers,
    Ready4Android

    ReplyDelete