Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * The MIT License
   *
   * Copyright 2010 Sony Ericsson Mobile Communications. 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.data;
 
Wrapper class for smoother serialization of and .

Author(s):
Robert Sandell <robert.sandell@sonyericsson.com>
 
 public class TriggeredItemEntity {
 
     private Integer buildNumber;
         private String projectId;
         private transient AbstractProject project;
         private transient AbstractBuild build;

        
Standard constructor.

Parameters:
buildNumber a buildNumber
projectId a project's full name.
 
         public TriggeredItemEntity(Integer buildNumberString projectId) {
             this. = buildNumber;
             this. = projectId;
         }

        
Standard Constructor.

Parameters:
project a project.
build a build.
 
         public TriggeredItemEntity(AbstractProject projectAbstractBuild build) {
             setProject(project);
             setBuild(build);
         }

        
Easy Constructor. The project will be set from .

Parameters:
build a build.
 
         public TriggeredItemEntity(AbstractBuild build) {
             setProject(build.getProject());
             setBuild(build);
         }

        
Easy Constructor.

Parameters:
project a project.
 
         public TriggeredItemEntity(AbstractProject project) {
             setProject(project);
             this. = null;
         }

        
Default constructor.
 
         public TriggeredItemEntity() {
         }

        
If this object contains a build.

Returns:
true if so.
 
         public boolean hasBuild() {
             return  != null;
         }

        
The build. If this object is newly deserialized, the build will be looked up via .

Returns:
the build.
 
        public AbstractBuild getBuild() {
            if ( == null) {
                if ( != null) {
                    getProject();
                    if ( != null) {
                         = (AbstractBuild).getBuildByNumber();
                    }
                }
            }
            return ;
        }

        
The build.

Parameters:
build the build.
        public void setBuild(AbstractBuild build) {
            this. = build;
             = build.getNumber();
        }

        
The project. If this object is newly deserialized, the project will be looked up from

Returns:
the project.
        public AbstractProject getProject() {
            if ( == null) {
                 = Hudson.getInstance().getItemByFullName(AbstractProject.class);
            }
            return ;
        }

        
The project.

Parameters:
project the project.
        public void setProject(AbstractProject project) {
            this. = project;
            this. = project.getFullName();
        }

        
The buildnumber if any yet.

Returns:
the build number.
        public Integer getBuildNumber() {
            return ;
        }

        
The buildnumber if any yet. Do not use this method unless you are a serializer!

Parameters:
buildNumber the build number.
        public void setBuildNumber(Integer buildNumber) {
            this. = buildNumber;
        }

        
The project's id.

Returns:
the id.
See also:
hudson.model.AbstractItem.getFullName()
        public String getProjectId() {
            return ;
        }

        
The project's id. Do not use this method unless you are a serializer!

Parameters:
projectId the id.
See also:
hudson.model.AbstractItem.getFullName()
        public void setProjectId(String projectId) {
            this. = projectId;
        }
        @Override
        public boolean equals(Object obj) {
            //CS IGNORE InlineConditionals FOR NEXT 17 LINES. REASON: Autogenerated.
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final TriggeredItemEntity other = (TriggeredItemEntity)obj;
            if (this. != other.buildNumber && (this. == null
                    || !this..equals(other.buildNumber))) {
                return false;
            }
            if ((this. == null) ? (other.projectId != null) : !this..equals(other.projectId)) {
                return false;
            }
            return true;
        }

        
If this object represents the same build as aBuild.

Parameters:
aBuild the build.
Returns:
true if it is so.
        public boolean equals(AbstractBuild aBuild) {
            if (this. != null) {
                return .equals(aBuild.getProject().getFullName())
                        && this..equals(aBuild.getNumber());
            }
            return false;
        }

        
If this object represents the same project as aProject.

Parameters:
aProject the project to compare.
Returns:
true if it is so.
        public boolean equals(AbstractProject aProject) {
            return .equals(aProject.getFullName());
        }
        @Override
        public int hashCode() {
            //CS IGNORE InlineConditionals FOR NEXT 5 LINES. REASON: Autogenerated code.
            //CS IGNORE MagicNumber FOR NEXT 5 LINES. REASON: Autogenerated code.
            int hash = 5;
            hash = 47 * hash + (this. != null ? this..hashCode() : 0);
            hash = 47 * hash + (this. != null ? this..hashCode() : 0);
            return hash;
        }
New to GrepCode? Check out our FAQ X