Hessu
Hessu

Reputation: 11

An interface for classes which extend Observable

I want to keep my business logic behind an interface (which is a good practice, I understand). I also want the business logic to be Observable, and Observable is a concrete class.

The other parts of the program need to know that the business logic both 1) implements my own interface, and 2) extends the Observable. And I need both, every time.

How do I do that?

Upvotes: 1

Views: 2413

Answers (2)

user207421
user207421

Reputation: 310859

public abstract class MyObservable extends Observable implements MyInterface {}

Upvotes: 3

Tom
Tom

Reputation: 44821

Rather than using an interface for your interface use an abstract class that extends Observable.

public abstract class MyType extends Observable {
    public abstract void doSomething();
    ...
}

Upvotes: 1

Related Questions