mercredi 9 mars 2022

Java overriding a abstract class method that were inherited by multiple subclasses [closed]

I have a question regarding OOP design in Java:

say I want to leverage a java library, which has Abstract class I and class A and B, A and B both extend I.

However, instead of using the library directly, I want to do some modifications of a concrete method f inside class I for my customized use case. After my modification, I would like A and B's f method both to use my new customized implementation instead of the original implementation.

I don't want to modify code in place of the original library (that means I have to create a forked repo and maintain that), what is the best design/abstraction/inheritance strategy I can use to achieve this modification?

Aucun commentaire:

Enregistrer un commentaire