/**
* @return true if the object can be added to the MapHandler, and
* will have removed the previous duplicate from the
* MapHandler.
*/
public boolean canAdd(BeanContextSupport bc, Object obj)
throws MultipleSoloMapComponentException {
if (obj == null) {
return false;
}
// At first we just added the new item, but we should remove
// the previous one, too.
if (obj instanceof SoloMapComponent) {
Class firstClass = obj.getClass();
for (Iterator it = bc.iterator(); it.hasNext();) {
Object someObj = it.next();
if (someObj instanceof SoloMapComponent) {
Class secondClass = someObj.getClass();
if (firstClass == secondClass
|| firstClass.isAssignableFrom(secondClass)
|| secondClass.isAssignableFrom(firstClass)) {
bc.remove(someObj);
break;
}
}
}
}
return true;
}
SoloMapComponentReplacePolicy.java 文件源码
java
阅读 24
收藏 0
点赞 0
评论 0
项目:passage
作者:
评论列表
文章目录