package hudson.plugins.git;

import com.google.common.base.Joiner;

import java.util.regex.Pattern;

public class SubmoduleConfig implements java.io.Serializable {
    private static final long serialVersionUID = 1L;
    String   submoduleName;
    String[] branches;

    public String getSubmoduleName() {
        return submoduleName;
    }

    public void setSubmoduleName(String submoduleName) {
        this.submoduleName = submoduleName;
    }

    public String[] getBranches() {
        return branches;
    }

    public void setBranches(String[] branches) {
        this.branches = branches;
    }

    public boolean revisionMatchesInterest(Revision r) {
        for (Branch br : r.getBranches()) {
            if (branchMatchesInterest(br)) return true;
        }
        return false;
    }

    public boolean branchMatchesInterest(Branch br) {
        for (String regex : branches) {
            if (!Pattern.matches(regex, br.getName())) {
                return false;
            }
        }
        return true;
    }

    public String getBranchesString() {
        return Joiner.on(',').join(branches);
    }
}

@@ -59,16 +59,41 @@
 .Joiner;
+%0Aimport java.util.Arrays;
 %0A%0Aimport
@@ -515,22 +515,62 @@
         
+/* findbugs correctly complains that 
 return
+ing
  branche
@@ -574,98 +574,708 @@
 ches
-;%0A    %7D%0A%0A    public void setBranches(String%5B%5D branches) %7B%0A        this.branches = branches
+ exposes the%0A         * internal representation of the class to callers.  Returning a copy%0A         * of the array does not expose internal representation, at the possible%0A         * expense of some additional memory.%0A         */%0A        return Arrays.copyOf(branches, branches.length);%0A    %7D%0A%0A    public void setBranches(String%5B%5D branches) %7B%0A        /* findbugs correctly complains that assign to branches exposes the%0A         * internal representation of the class to callers.  Assigning a copy%0A         * of the array does not expose internal representation, at the possible%0A         * expense of some additional memory.%0A         */%0A        this.branches = Arrays.copyOf(branches, branches.length)
 ;%0A  

Return copy of String array rather than returning internal String array