Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  The MIT License
   *
   *  Copyright 2010 Sony Ericsson Mobile Communications. All rights reserved.
   *  Copyright 2012 Sony Mobile Communications AB. All rights reserved.
   *
   *  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.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger;
 
A Cause why a build was scheduled.

Author(s):
Robert Sandell <robert.sandell@sonyericsson.com>
 
 public class GerritCause extends Cause {
 
     private GerritTriggeredEvent tEvent;
     private boolean silentMode;
     private TriggerContext context;

    
Default DataBound Constructor.

Parameters:
event the event that triggered the build.
silentMode Silent Mode on or off.
 
     public GerritCause(GerritTriggeredEvent eventboolean silentMode) {
         this. = event;
         this. = silentMode;
         this. = new TriggerContext(event);
     }

    
Default DataBound Constructor.

Parameters:
event the event that triggered the build.
silentMode Silent Mode on or off.
context The context with information about other builds triggered for the same event as this one.
 
     public GerritCause(GerritTriggeredEvent eventboolean silentModeTriggerContext context) {
         this. = event;
         this. = silentMode;
         this. = context;
     }

    
Default Constructor.
 
     public GerritCause() {
     }

    
The event.

Returns:
the event.
 
     public GerritTriggeredEvent getEvent() {
         return ;
     }

    
The event.

Parameters:
event the event.
 
     public void setEvent(GerritTriggeredEvent event) {
         this. = event;
     }

    
Gets the indication if silent mode was on or off when the build was triggered. When silent mode is on there will be no communication back to Gerrit, i.e. no build started/failed/successful approve messages etc. Default is false.

Returns:
true if silent mode was on.
See also:
GerritTrigger.isSilentMode()
 
     public boolean isSilentMode() {
        return ;
    }

    
Sets the indication if silent mode was on or off when the build was triggered. When silent mode is on there will be no communication back to Gerrit, i.e. no build started/failed/successful approve messages etc. Default is false.

Parameters:
silentMode true if silent mode was on.
See also:
GerritTrigger.setSilentMode(boolean)
    public void setSilentMode(boolean silentMode) {
        this. = silentMode;
    }

    
The context with information about other builds triggered for the same event as this one.

Returns:
the context.
    public TriggerContext getContext() {
        return ;
    }

    
The context with information about other builds triggered for the same event as this one.

Parameters:
context the context.
    public void setContext(TriggerContext context) {
        this. = context;
    }

    
Gives the short description of the GerritCause. Intended to be overridden by subclasses.

Returns:
the short description.
See also:
getShortGerritDescriptionSilentMode()
getShortDescription()
    protected String getShortGerritDescription() {
        return Messages.TriggeredShortDescription(getUrl());
    }

    
Gives the short description of the GerritCause in silent mode. Intended to be overridden by subclasses.

Returns:
the short description for silent mode.
See also:
getShortGerritDescription()
getShortDescription()
        return Messages.TriggeredShortDescriptionInSilentMode(getUrl());
    }
    @Override
    public String getShortDescription() {
        if (isSilentMode()) {
            return getShortGerritDescriptionSilentMode();
        } else {
            return getShortGerritDescription();
        }
    }

    
Gets the URL to the Gerrit patchSet.

Returns:
the URL.
    public String getUrl() {
        if ( instanceof ChangeBasedEvent) {
            ChangeBasedEvent changeBasedEvent = (ChangeBasedEvent);
            return PluginImpl.getInstance().getConfig().getGerritFrontEndUrlFor(
                    changeBasedEvent.getChange().getNumber(),
                    changeBasedEvent.getPatchSet().getNumber());
        }
        return PluginImpl.getInstance().getConfig().getGerritFrontEndUrl();
    }
    @Override
    public String toString() {
        return "GerritCause: " +  + " silent: " + ;
    }
    //CS IGNORE InlineConditionals FOR NEXT 40 LINES. REASON: Auto generated code
    //CS IGNORE MagicNumber FOR NEXT 40 LINES. REASON: Auto generated code
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GerritCause that = (GerritCause)o;
        if ( != that.silentMode) {
            return false;
        }
        if (!.equals(that.tEvent)) {
            return false;
        }
        return true;
    }
    @Override
    public int hashCode() {
        int result = .hashCode();
        result = 31 * result + ( ? 1 : 0);
        return result;
    }
    @Deprecated //Kept for backwards compatibility
    private transient PatchsetCreated event;

    
For backwards compatibility event is kept to be able to deserialize old builds, here event gets resolved to the more abstract version.

Returns:
the resolved instance.
    Object readResolve() {
        if (this. != null) {
            this. = this.;
            this. = null;
        }
        return this;
    }
New to GrepCode? Check out our FAQ X