// Path: src/main/java/org/jenkinsci/plugins/ghprb/extensions/GhprbExtension.java
// public abstract class GhprbExtension extends AbstractDescribableImpl<GhprbExtension> {
// 
// }
// 
// Path: src/main/java/org/jenkinsci/plugins/ghprb/extensions/GhprbExtensionDescriptor.java
// @SuppressWarnings("unchecked")
// public abstract class GhprbExtensionDescriptor extends Descriptor<GhprbExtension> {
//     public boolean isApplicable(Class<?> type) {
//         return true;
//     }
// 
//     public static List<GhprbExtensionDescriptor> getExtensions(Class<? extends GhprbExtensionType>... types) {
//         List<GhprbExtensionDescriptor> list = getExtensions();
//         filterExtensions(list, types);
//         return list;
//     }
// 
//     private static void filterExtensions(List<GhprbExtensionDescriptor> descriptors, Class<? extends GhprbExtensionType>... types) {
//         List<Predicate> predicates = new ArrayList<Predicate>(types.length);
//         for (Class<? extends GhprbExtensionType> type : types) {
//             predicates.add(InstanceofPredicate.getInstance(type));
// 
//         }
//         Predicate anyPredicate = PredicateUtils.anyPredicate(predicates);
//         Iterator<GhprbExtensionDescriptor> iter = descriptors.iterator();
//         while (iter.hasNext()) {
//             GhprbExtensionDescriptor descriptor = iter.next();
//             if (!anyPredicate.evaluate(descriptor)) {
//                 iter.remove();
//             }
//         }
//     }
// 
//     private static DescriptorExtensionList<GhprbExtension, GhprbExtensionDescriptor> getExtensionList() {
//         return Jenkins.getInstance().getDescriptorList(GhprbExtension.class);
//     }
// 
//     /**
//      * Don't mutate the list from Jenkins, they will persist;
//      *
//      * @return list of extensions
//      */
//     private static List<GhprbExtensionDescriptor> getExtensions() {
//         List<GhprbExtensionDescriptor> list = new ArrayList<GhprbExtensionDescriptor>();
//         list.addAll(getExtensionList());
//         return list;
//     }
// 
//     public static List<GhprbExtensionDescriptor> allProject() {
//         List<GhprbExtensionDescriptor> list = getExtensions();
//         filterExtensions(list, GhprbProjectExtension.class);
//         return list;
//     }
// 
//     public static List<GhprbExtensionDescriptor> allGlobal() {
//         List<GhprbExtensionDescriptor> list = getExtensions();
//         filterExtensions(list, GhprbGlobalExtension.class);
//         return list;
//     }
// 
// }


import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.CredentialsStore;
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
import com.cloudbees.plugins.credentials.common.StandardCredentials;
import com.cloudbees.plugins.credentials.domains.Domain;
import com.cloudbees.plugins.credentials.domains.DomainSpecification;
import com.cloudbees.plugins.credentials.domains.HostnamePortSpecification;
import com.cloudbees.plugins.credentials.domains.HostnameSpecification;
import com.cloudbees.plugins.credentials.domains.PathSpecification;
import com.cloudbees.plugins.credentials.domains.SchemeSpecification;
import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder;
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.Cause;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.Saveable;
import hudson.model.TaskListener;
import hudson.security.ACL;
import hudson.util.DescribableList;
import hudson.util.Secret;
import jenkins.model.ParameterizedJobMixIn;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.PredicateUtils;
import org.apache.commons.collections.functors.InstanceofPredicate;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.ghprb.extensions.GhprbExtension;
import org.jenkinsci.plugins.ghprb.extensions.GhprbExtensionDescriptor;
import org.jenkinsci.plugins.ghprb.extensions.GhprbProjectExtension;
import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl;
import org.kohsuke.github.GHCommitState;
import org.kohsuke.github.GHIssue;
import org.kohsuke.github.GHUser;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
            }
        }

        return copyExtensions;
    }

    private static boolean addExtension(GhprbExtension extension, List<Predicate> predicates, Set<Class<?>> extSet) {
        for (Predicate predicate : predicates) {
            if (predicate.evaluate(extension)) {
                Class<?> clazz = ((InstanceofPredicate) predicate).getType();
                if (extSet.contains(clazz)) {
                    return false;
                } else {
                    extSet.add(clazz);
                    return true;
                }
            }
        }
        return true;
    }

    public static void addIfMissing(
            DescribableList<GhprbExtension, GhprbExtensionDescriptor> extensions,
            GhprbExtension ext,
            Class<?> type
    ) {
        if (ext == null) {
            return;
        }
        Predicate predicate = InstanceofPredicate.getInstance(type);
// Path: src/main/java/org/jenkinsci/plugins/ghprb/extensions/GhprbExtension.java
// public abstract class GhprbExtension extends AbstractDescribableImpl<GhprbExtension> {
// 
// }
// 
// Path: src/main/java/org/jenkinsci/plugins/ghprb/extensions/GhprbExtensionDescriptor.java
// @SuppressWarnings("unchecked")
// public abstract class GhprbExtensionDescriptor extends Descriptor<GhprbExtension> {
//     public boolean isApplicable(Class<?> type) {
//         return true;
//     }
// 
//     public static List<GhprbExtensionDescriptor> getExtensions(Class<? extends GhprbExtensionType>... types) {
//         List<GhprbExtensionDescriptor> list = getExtensions();
//         filterExtensions(list, types);
//         return list;
//     }
// 
//     private static void filterExtensions(List<GhprbExtensionDescriptor> descriptors, Class<? extends GhprbExtensionType>... types) {
//         List<Predicate> predicates = new ArrayList<Predicate>(types.length);
//         for (Class<? extends GhprbExtensionType> type : types) {
//             predicates.add(InstanceofPredicate.getInstance(type));
// 
//         }
//         Predicate anyPredicate = PredicateUtils.anyPredicate(predicates);
//         Iterator<GhprbExtensionDescriptor> iter = descriptors.iterator();
//         while (iter.hasNext()) {
//             GhprbExtensionDescriptor descriptor = iter.next();
//             if (!anyPredicate.evaluate(descriptor)) {
//                 iter.remove();
//             }
//         }
//     }
// 
//     private static DescriptorExtensionList<GhprbExtension, GhprbExtensionDescriptor> getExtensionList() {
//         return Jenkins.getInstance().getDescriptorList(GhprbExtension.class);
//     }
// 
//     /**
//      * Don't mutate the list from Jenkins, they will persist;
//      *
//      * @return list of extensions
//      */
//     private static List<GhprbExtensionDescriptor> getExtensions() {
//         List<GhprbExtensionDescriptor> list = new ArrayList<GhprbExtensionDescriptor>();
//         list.addAll(getExtensionList());
//         return list;
//     }
// 
//     public static List<GhprbExtensionDescriptor> allProject() {
//         List<GhprbExtensionDescriptor> list = getExtensions();
//         filterExtensions(list, GhprbProjectExtension.class);
//         return list;
//     }
// 
//     public static List<GhprbExtensionDescriptor> allGlobal() {
//         List<GhprbExtensionDescriptor> list = getExtensions();
//         filterExtensions(list, GhprbGlobalExtension.class);
//         return list;
//     }
// 
// }


// Path: src/main/java/org/jenkinsci/plugins/ghprb/Ghprb.java
import com.cloudbees.plugins.credentials.CredentialsMatchers;
import com.cloudbees.plugins.credentials.CredentialsProvider;
import com.cloudbees.plugins.credentials.CredentialsScope;
import com.cloudbees.plugins.credentials.CredentialsStore;
import com.cloudbees.plugins.credentials.SystemCredentialsProvider;
import com.cloudbees.plugins.credentials.common.StandardCredentials;
import com.cloudbees.plugins.credentials.domains.Domain;
import com.cloudbees.plugins.credentials.domains.DomainSpecification;
import com.cloudbees.plugins.credentials.domains.HostnamePortSpecification;
import com.cloudbees.plugins.credentials.domains.HostnameSpecification;
import com.cloudbees.plugins.credentials.domains.PathSpecification;
import com.cloudbees.plugins.credentials.domains.SchemeSpecification;
import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder;
import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl;
import hudson.Util;
import hudson.model.AbstractBuild;
import hudson.model.Cause;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.Result;
import hudson.model.Run;
import hudson.model.Saveable;
import hudson.model.TaskListener;
import hudson.security.ACL;
import hudson.util.DescribableList;
import hudson.util.Secret;
import jenkins.model.ParameterizedJobMixIn;
import org.apache.commons.collections.Predicate;
import org.apache.commons.collections.PredicateUtils;
import org.apache.commons.collections.functors.InstanceofPredicate;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.ghprb.extensions.GhprbExtension;
import org.jenkinsci.plugins.ghprb.extensions.GhprbExtensionDescriptor;
import org.jenkinsci.plugins.ghprb.extensions.GhprbProjectExtension;
import org.jenkinsci.plugins.plaincredentials.impl.StringCredentialsImpl;
import org.kohsuke.github.GHCommitState;
import org.kohsuke.github.GHIssue;
import org.kohsuke.github.GHUser;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;

            }
        }

        return copyExtensions;
    }

    private static boolean addExtension(GhprbExtension extension, List<Predicate> predicates, Set<Class<?>> extSet) {
        for (Predicate predicate : predicates) {
            if (predicate.evaluate(extension)) {
                Class<?> clazz = ((InstanceofPredicate) predicate).getType();
                if (extSet.contains(clazz)) {
                    return false;
                } else {
                    extSet.add(clazz);
                    return true;
                }
            }
        }
        return true;
    }

    public static void addIfMissing(
            DescribableList<GhprbExtension, GhprbExtensionDescriptor> extensions,
            GhprbExtension ext,
            Class<?> type
    ) {
        if (ext == null) {
            return;
        }
        Predicate predicate = InstanceofPredicate.getInstance(type);
        for (GhprbExtension extension : extensions) {