canUseAlias = !isAliasInUse(alias);
return !isAliasInUse(alias); }  boolean canUseAlias = false; Collection bids = getBeanIdsOfObjectsWithAlias(alias); int size = bids.size(); if (size == 0) {  canUseAlias = true; } else if (size == 1) {   BeanId bid = (BeanId) bids.iterator().next(); canUseAlias = bid.isIdOfBean(bean); if (LOG.isInfoEnabled() && !canUseAlias) { String msg = MessageFormat.format("Alias \"{0}\" is in use by: {1}", new Object[] { alias, bid.toString() }); LOG.info(msg); }
    public boolean canObjectUseAlias(BeanWithId bean, String alias) {        if (alias == null) {            return true;        }        boolean canUseAlias = false;        if (bean.isNew()) {            // For a new bean, if there is any database object that has already claimed            // the alias, then this bean cannot use it            canUseAlias = !isAliasInUse(alias);        } else {            Collection bids = getBeanIdsOfObjectsWithAlias(alias);            int size = bids.size();            if (size == 0) {                // No one is using the alias so we can take it                canUseAlias = true;            } else if (size == 1) {                // One object is using the alias.  If that object is the bean itself, then                // it's OK for the bean to use the alias, otherwise not.                BeanId bid = (BeanId) bids.iterator().next();                canUseAlias = bid.isIdOfBean(bean);                if (LOG.isInfoEnabled() && !canUseAlias) {                    LOG.info("Alias \"" + alias + "\" is in use by: " + bid.toString());                }            } else {                // More than one object is using the alias!  If the bean is one of them,                // then the bean can continue to use the alias, but log an error in any                // case because the database is messed up.                for (Iterator iter = bids.iterator(); iter.hasNext();) {                    BeanId bid = (BeanId) iter.next();                    if (bid.isIdOfBean(bean)) {                        canUseAlias = true;                        break;                    }                }                // Construct this string carefully to avoid bogus checkstyle duplicate string errors (arrrgh!)                StringBuffer buf = new StringBuffer("Alias " + "\"" + alias + "\" is being used by multiple objects:");                for (Iterator iter = bids.iterator(); iter.hasNext();) {                    Object obj = (Object) iter.next();                    buf.append(" ");                    buf.append(obj);                }                LOG.error(buf.toString());            }        }        return canUseAlias;           }