Package org.jenkinsci.plugins.workflow.support.steps.input

Source Code of org.jenkinsci.plugins.workflow.support.steps.input.Rejection

package org.jenkinsci.plugins.workflow.support.steps.input;

import hudson.model.User;
import javax.annotation.CheckForNull;
import jenkins.model.CauseOfInterruption;
import org.kohsuke.stapler.export.Exported;

/**
* Indicates that the input step was rejected by the user.
*/
public final class Rejection extends CauseOfInterruption {

    private final @CheckForNull String userName;
    private final long timestamp;

    public Rejection(@CheckForNull User u) {
        this.userName = u==null ? null : u.getId();
        this.timestamp = System.currentTimeMillis();
    }

    /**
     * Gets the user who rejected this.
     */
    @Exported
    public @CheckForNull User getUser() {
        return userName != null ? User.get(userName) : null;
    }

    /**
     * Gets the timestamp when the rejection occurred.
     */
    @Exported
    public long getTimestamp() {
        return timestamp;
    }

    @Override public String getShortDescription() {
        User u = getUser();
        if (u != null) {
            return "Rejected by " + u.getDisplayName();
        } else {
            return "Rejected";
        }
    }

}
TOP

Related Classes of org.jenkinsci.plugins.workflow.support.steps.input.Rejection

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.