Answer the question
In order to leave comments, you need to log in
How to exclude a property from an interface?
Typescript has a special type Omit
that is used like this:
interface MyInterface {
A: string;
B: string;
C: string;
}
class MyClass implements Omit<MyInterface, 'C'> {
public A: string = '';
public B: string = '';
}
Answer the question
In order to leave comments, you need to log in
In Java, this is not allowed. Either the class implements the interface completely, or it does not conform to the given interface.
It would be correct to throw an "UnsupportedOperationException" or "NotImplementedException" exception in the implementation of the method, and indicate in the documentation for the method why this method is not implemented.
Another option is to change the interface, in one of the ways and depending on why you need to not implement one of the methods:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question