/* * The MIT License * * Copyright 2013 Ericsson. * * 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.sonymobile.tools.gerrit.gerritevents.dto.events; import static com.sonymobile.tools.gerrit.gerritevents.GerritJsonEventFactory.getString; import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.NODES_COUNT; import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.PROJECT; import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.REF; import net.sf.json.JSONObject; import com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventType; /** * A DTO representation of the ref-replication-done Gerrit Event. * * @author Hugo Arès <hugo.ares@ericsson.com> */ public class RefReplicationDone extends GerritTriggeredEvent { /** * Project path in Gerrit. */ private String project; /** * Ref name within project. */ private String ref; /** * Number of nodes the replication was done to. */ private int nodesCount; @Override public GerritEventType getEventType() { return GerritEventType.REF_REPLICATION_DONE; } @Override public boolean isScorable() { return false; } @Override public void fromJson(JSONObject json) { project = getString(json, PROJECT); ref = getString(json, REF); nodesCount = json.getInt(NODES_COUNT); super.fromJson(json); } /** * Project name. * @return the project */ public String getProject() { return project; } /** * Project name. * @param project the project to set */ public void setProject(String project) { this.project = project; } /** * Ref within the project. * @return the ref */ public String getRef() { return ref; } /** * Ref within the project. * @param ref the ref to set */ public void setRef(String ref) { this.ref = ref; } /** * Number of nodes the replication was done to. * @return the nodesCount */ public int getNodesCount() { return nodesCount; } /** * Number of nodes the replication was done to. * @param nodesCount the nodesCount to set */ public void setNodesCount(int nodesCount) { this.nodesCount = nodesCount; } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ @Override public int hashCode() { //CS IGNORE MagicNumber FOR NEXT 5 LINES. REASON: Autogenerated Code. //CS IGNORE AvoidInlineConditionals FOR NEXT 5 LINES. REASON: Autogenerated Code. final int prime = 31; int result = 1; result = prime * result + nodesCount; result = prime * result + ((project == null) ? 0 : project.hashCode()); result = prime * result + ((ref == null) ? 0 : ref.hashCode()); return result; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } RefReplicationDone other = (RefReplicationDone)obj; if (nodesCount != other.nodesCount) { return false; } if (project == null) { if (other.project != null) { return false; } } else if (!project.equals(other.project)) { return false; } if (ref == null) { if (other.ref != null) { return false; } } else if (!ref.equals(other.ref)) { return false; } return true; } @Override public String toString() { return "RefReplicationDone [project=" + project + ", ref=" + ref + ", nodesCount=" + nodesCount + "]"; } }