JiBX should search for add-method in declared create-type, not collections 
interface type
-----------------------------------------------------------------------------------------

                 Key: JIBX-430
                 URL: http://jira.codehaus.org/browse/JIBX-430
             Project: JiBX
          Issue Type: Bug
          Components: core
    Affects Versions: JiBX 1.2.3
            Reporter: Archie Cobbs


I created a subclass of {{HashSet}} with an {{addUnique}} method that {{throws 
JiBXException}} if the item already exists in the set:
{noformat}
public class ListableHashSet<E> extends LinkedHashSet<E> {

    ...

    /**
     * Add an item to a set while verifying that the item is not already in the 
set.
     *
     * @throws JiBXException if item is already in the set
     */
    public void addUnique(E item) throws JiBXException {
        if (this.contains(item))
            throw new JiBXException("duplicate item in set: " + item);
        this.add(item);
    }
}
{noformat}
Then I tried to use this method as the {{add-method}} as follows:
{noformat}
<binding package="com.example">
    <mapping abstract="true" type-name="user" class="com.example.User">
        <value name="username" field="username"/>
        <value name="passwordHash" field="passwordHash"/>
        <collection name="Roles" field="roles" 
create-type="com.example.MyHashSet" add-method="addUnique">
            <value name="role" type="com.example.RoleType"/>
        </collection>
    </mapping>
</binding>
{noformat}
But doing so causes this binding error:
{noformat}
Error: add-method addUnique not found in class java.util.Set; on collection 
element at ...
{noformat}

The bug here is that JiBX is looking for the {{addUnique}} method in the class 
{{java.util.Set}} instead of {{com.example.MyHashSet}}.

JiBX should be searching for {{add-methods}} in the declared {{create-type}} 
class, not the collection interface class.



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
jibx-devs mailing list
jibx-devs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to