SoloMapComponentRejectPolicy.java 文件源码

java
阅读 44 收藏 0 点赞 0 评论 0

项目:passage 作者:
/**
 * @throws a MultipleSoloMapComponentException if a duplicate
 *         instance of SoloMapComponent exists.
 * @return true if the object can be added to the MapHandler.
 */
public boolean canAdd(BeanContextSupport bc, Object obj)
        throws MultipleSoloMapComponentException {
    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)) {

                    throw new MultipleSoloMapComponentException(firstClass, secondClass);
                }
            }
        }
    }
    return true;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号