我在 magnolia CMS 源代码中找到了这个类,它使用了我还不熟悉的类定义。任何了解使用以下代码样式的人都可以向我解释这到底是做什么的吗?
在此代码示例中RenderingModel
和RenderableDefinition
都是接口。据我所知,我们不能在一个类中实现两个接口,但这里是通过其他方式实现的。有人可以向我解释一下以下行中使用的技术吗:
public class RenderingModelImpl < RD extends RenderableDefinition >
implements RenderingModel {
以下是您可以在magnolia java docs中找到的完整类
public class RenderingModelImpl < RD
extends RenderableDefinition >
implements RenderingModel {
protected final RenderingModel parentModel;
protected final Content content;
protected final RD definition;
public RenderingModelImpl(Content content, RD definition, RenderingModel
parent) {
this.content = content;
this.definition = definition;
this.parentModel = parent;
}
public RenderingModel getParent() {
return this.parentModel;
}
public RenderingModel getRoot(){
RenderingModel model = this;
while(model.getParent() != null){
model = model.getParent();
}
return model;
}
public Content getContent() {
return this.content;
}
/**
* Shortname for templates: model.def.
*/
public RD getDef() {
return getDefinition();
}
public RD getDefinition() {
return this.definition;
}
public String execute() {
return null;
}
}