2
我使用EMF通过注释的Java代码如下生成方法返回EMF不可修改的列表
/**
* Adds the given type to this filter. Has no effect if the given type
* already belongs to this filter.
*
* @param type
* the type to add
* @model
*/
public void addEntityType(String type);
/**
* Returns the list of types belonging to this filter. Types are identified
* by there name.
*
* @return the list of types for this entity type filter
*
* @model
*/
public List<String> getEntityTypes();
/**
* Removes the given type from this filter. Has no effect if the given type
* doesn't belong to this filter.
*
* @param type
* the type to remove
* @model
*/
public void removeEntityType(String type);
从这个注释的接口建立的Ecore和这个genmodel文件后,并生成代码后getEntityTypes方法修改如下:
public EList<String> getEntityTypes();
为了封装的目的,我希望这个EList是不可修改的,因此接口客户端的代码只能通过添加和删除方法来修改列表。
是否有任何干净的方式来做到这一点,即修改Java注释或genmodel文件以告诉生成器生成返回不可修改列表的代码? (Google搜寻后我无法找到...)
你如何管理这种情况?
在此先感谢
马努