编辑外部库 [英] Editing an external library
问题描述
我在项目中有一个外部库:
I have an external library in the project:
该项目使用该库中的方法
The project uses methods from this library
对我来说,该库中的类是只读的
For me, the classes in this library are read-only
我需要从外部库中稍微更改方法逻辑
I need to change the method logic from an external library a little bit
我应该怎么做?
也许我应该使用相同的逻辑在项目中创建新类?(+我的更改)
Maybe I should create new class in project with the same logic? (+ my changes)
也许还有其他解决方案?
Maybe other solutions?
推荐答案
如果使用 Kotlin
,则可以使用扩展功能
扩展类功能,而无需扩展
它.您可以使用 Java
扩展类,并对其进行 override
或 add
方法.无需复制/粘贴类即可添加新功能.
If you use Kotlin
you could use Extension Function
to extend class functionalities with no need to extend
it. You use Java
you could extend the classes and override
or add
methods to it. There is no need to copy/paste class to add new functionalities.
这篇关于编辑外部库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!