[ 
https://issues.apache.org/jira/browse/DDLUTILS-209?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12604168#action_12604168
 ] 

Rijk van Haaften commented on DDLUTILS-209:
-------------------------------------------

Suggested implementation (tested code):

    /**
     * Finds the foreign key in this table with the specified name,
     * using case insensitive matching.
     * Note that this method is not called getForeignKey to avoid introspection
     * problems.
     * 
     * @param name The name of the foreign key
     * @return The index or <code>null</code> if there is no such index
     */
    public ForeignKey findForeignKey(String name)
    {
        return findForeignKey(name, false);
    }

    /**
     * Finds the foreign key in this table with the specified name,
     * using given case-sensitivity.
     * Note that this method is not called getForeignKey to avoid introspection
     * problems.
     * 
     * @param name          The name of the index
     * @param caseSensitive Whether case matters for the names
     * @return The index or <code>null</code> if there is no such index
     */
    public ForeignKey findForeignKey(String name, boolean caseSensitive)
    {
        for (int idx = 0; idx < getForeignKeyCount(); idx++)
        {
            ForeignKey fk = getForeignKey(idx);

            if ((caseSensitive  && fk.getName().equals(name)) ||
                (!caseSensitive && fk.getName().equalsIgnoreCase(name)))
            {
                return fk;
            }
        }
        return null;
    }


> Table.findForeignKey
> --------------------
>
>                 Key: DDLUTILS-209
>                 URL: https://issues.apache.org/jira/browse/DDLUTILS-209
>             Project: DdlUtils
>          Issue Type: Improvement
>          Components: Core (No specific database)
>    Affects Versions: 1.0
>         Environment: Any
>            Reporter: Rijk van Haaften
>            Assignee: Thomas Dudziak
>            Priority: Minor
>
> There is:
> Table.findColumn(String)
> Table.findIndex(String)
> but
> Table.findForeignKey(ForeignKey)
> Suggestion: add Table.findForeignKey(String)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to