// Path: src/main/java/com/synopsys/arc/jenkinsci/plugins/jobrestrictions/restrictions/JobRestrictionDescriptor.java
// public abstract class JobRestrictionDescriptor extends Descriptor<JobRestriction> {
//     public JobRestrictionDescriptor getDefaultSettingsProvider() {
//         return (JobRestrictionDescriptor)JobRestriction.all().find(AnyJobRestriction.class);
//     } 
// }
// 
// Path: src/main/java/com/synopsys/arc/jenkinsci/plugins/jobrestrictions/util/UserSelector.java
// public class UserSelector implements Describable<UserSelector>, Serializable {
//     
//     /**ID of the user*/
//     @CheckForNull String selectedUserId;
// 
//     @DataBoundConstructor
//     public UserSelector(@CheckForNull String selectedUserId) {
//         this.selectedUserId = hudson.Util.fixEmptyAndTrim(selectedUserId);
//     }
// 
//     @CheckForNull
//     public String getSelectedUserId() {
//         return selectedUserId;
//     }
// 
//     @Override
//     public Descriptor<UserSelector> getDescriptor() {
//         return DESCRIPTOR;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {       
//         if (obj instanceof UserSelector) {
//             UserSelector cmp = (UserSelector)obj;
//             return selectedUserId != null ? selectedUserId.equals(cmp.selectedUserId) : cmp.selectedUserId == null;
//         }           
//         return false;    
//     }
// 
//     @Override
//     public int hashCode() {
//         int hash = 7;
//         hash = 17 * hash + (selectedUserId != null ? selectedUserId.hashCode() : 0);
//         return hash;
//     }
//           
//     @Extension
//     public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
//     public static class DescriptorImpl extends Descriptor<UserSelector> {
//         
//         @Override
//         public String getDisplayName() {
//             return "N/A";
//         }
// 
//         @Restricted(NoExternalUse.class) // Stapler only
//         public FormValidation doCheckSelectedUserId(@QueryParameter String selectedUserId) {
//             selectedUserId = Util.fixEmptyAndTrim(selectedUserId);
//             if (selectedUserId == null) {
//                 return FormValidation.error("Field is empty");
//             }
// 
//             User user = User.getById(selectedUserId, false);
//             if (user == null) {
//                 return FormValidation.warning("User " + selectedUserId + " is not registered in Jenkins");
//             }
// 
//             return FormValidation.ok();
//         }
//     }
// }


import java.util.List;
import java.util.Set;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.kohsuke.stapler.DataBoundConstructor;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.Messages;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.restrictions.JobRestrictionDescriptor;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.util.UserSelector;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import java.util.HashSet;
/*
 * The MIT License
 *
 * Copyright 2014-2016 Oleg Nenashev
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.synopsys.arc.jenkinsci.plugins.jobrestrictions.restrictions.job;


/**
 * Handles restrictions from User causes.
 * @author Oleg Nenashev
 * @since 0.4
 */
// TODO: it's a real issue, needs some love
@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", 
        justification = "XStream does actually need serialization, the code needs refactoring in 1.0")
public class StartedByUserRestriction extends AbstractUserCauseRestriction {
    
// Path: src/main/java/com/synopsys/arc/jenkinsci/plugins/jobrestrictions/restrictions/JobRestrictionDescriptor.java
// public abstract class JobRestrictionDescriptor extends Descriptor<JobRestriction> {
//     public JobRestrictionDescriptor getDefaultSettingsProvider() {
//         return (JobRestrictionDescriptor)JobRestriction.all().find(AnyJobRestriction.class);
//     } 
// }
// 
// Path: src/main/java/com/synopsys/arc/jenkinsci/plugins/jobrestrictions/util/UserSelector.java
// public class UserSelector implements Describable<UserSelector>, Serializable {
//     
//     /**ID of the user*/
//     @CheckForNull String selectedUserId;
// 
//     @DataBoundConstructor
//     public UserSelector(@CheckForNull String selectedUserId) {
//         this.selectedUserId = hudson.Util.fixEmptyAndTrim(selectedUserId);
//     }
// 
//     @CheckForNull
//     public String getSelectedUserId() {
//         return selectedUserId;
//     }
// 
//     @Override
//     public Descriptor<UserSelector> getDescriptor() {
//         return DESCRIPTOR;
//     }
// 
//     @Override
//     public boolean equals(Object obj) {       
//         if (obj instanceof UserSelector) {
//             UserSelector cmp = (UserSelector)obj;
//             return selectedUserId != null ? selectedUserId.equals(cmp.selectedUserId) : cmp.selectedUserId == null;
//         }           
//         return false;    
//     }
// 
//     @Override
//     public int hashCode() {
//         int hash = 7;
//         hash = 17 * hash + (selectedUserId != null ? selectedUserId.hashCode() : 0);
//         return hash;
//     }
//           
//     @Extension
//     public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
//     public static class DescriptorImpl extends Descriptor<UserSelector> {
//         
//         @Override
//         public String getDisplayName() {
//             return "N/A";
//         }
// 
//         @Restricted(NoExternalUse.class) // Stapler only
//         public FormValidation doCheckSelectedUserId(@QueryParameter String selectedUserId) {
//             selectedUserId = Util.fixEmptyAndTrim(selectedUserId);
//             if (selectedUserId == null) {
//                 return FormValidation.error("Field is empty");
//             }
// 
//             User user = User.getById(selectedUserId, false);
//             if (user == null) {
//                 return FormValidation.warning("User " + selectedUserId + " is not registered in Jenkins");
//             }
// 
//             return FormValidation.ok();
//         }
//     }
// }


// Path: src/main/java/com/synopsys/arc/jenkinsci/plugins/jobrestrictions/restrictions/job/StartedByUserRestriction.java
import java.util.List;
import java.util.Set;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import org.kohsuke.stapler.DataBoundConstructor;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.Messages;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.restrictions.JobRestrictionDescriptor;
import com.synopsys.arc.jenkinsci.plugins.jobrestrictions.util.UserSelector;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import java.util.HashSet;

/*
 * The MIT License
 *
 * Copyright 2014-2016 Oleg Nenashev
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.synopsys.arc.jenkinsci.plugins.jobrestrictions.restrictions.job;


/**
 * Handles restrictions from User causes.
 * @author Oleg Nenashev
 * @since 0.4
 */
// TODO: it's a real issue, needs some love
@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", 
        justification = "XStream does actually need serialization, the code needs refactoring in 1.0")
public class StartedByUserRestriction extends AbstractUserCauseRestriction {
    
    private final List<UserSelector> usersList; 