Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java interface inheritance and implementation [duplicate]

I saw in the apache camel source code that

public class DefaultCamelContext extends ServiceSupport implements CamelContext, Service

My question is why this definition since

public interface CamelContext extends Service

and also

public abstract class ServiceSupport implements Service

Shouldn't it be just

public class DefaultCamelContext extends ServiceSupport implements CamelContext

?

Is the explicit 'implements Service' needed and I am missing something? Generally is there any case where this might be needed?

like image 712
Paralife Avatar asked Dec 12 '25 22:12

Paralife


1 Answers

It's not needed, but it emphasizes to anyone reading the code that it really does implement Service - it means they don't need to look at ServiceSupport to find that out.

I don't tend to do it myself, but there's nothing wrong with doing it.

like image 136
Jon Skeet Avatar answered Dec 16 '25 00:12

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!