// Path: src/main/java/com/sonymobile/tools/gerrit/gerritevents/dto/GerritEventKeys.java
// public static final String PROJECT = "project";
// 
// Path: src/main/java/com/sonymobile/tools/gerrit/gerritevents/dto/GerritEventKeys.java
// public static final String REFNAME = "refName";
// 
// Path: src/main/java/com/sonymobile/tools/gerrit/gerritevents/dto/GerritEventKeys.java
// public static final String OLDREV = "oldRev";
// 
// Path: src/main/java/com/sonymobile/tools/gerrit/gerritevents/dto/GerritEventKeys.java
// public static final String NEWREV = "newRev";


import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.NEWREV;
import com.sonymobile.tools.gerrit.gerritevents.dto.GerritJsonDTO;
import static com.sonymobile.tools.gerrit.gerritevents.GerritJsonEventFactory.getString;
import net.sf.json.JSONObject;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.PROJECT;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.REFNAME;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.OLDREV;
/*
 *  The MIT License
 *
 *  Copyright 2012 Hewlett-Packard Development Company, L.P.
 *
 *  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.attr;



/**
 * Represents a Gerrit JSON Reference Updated DTO.
 * @author James E. Blair &lt;jeblair@hp.com&gt;
 */
public class RefUpdate implements GerritJsonDTO {

    private static final String REFS_HEADS = "refs/heads/";
    /**
     * Project path in Gerrit.
     */
    private String project;
    /**
     * Ref name within project.
     */
    private String refName;
    /**
     * Old revision at ref.
     */
    private String oldRev;
    /**
     * New revision at ref.
     */
    private String newRev;

    /**
     * Default constructor.
     */
    public RefUpdate() {
    }

    /**
     * Constructor that fills with data directly.
     * @param json the JSON Object with corresponding data.
     * @see #fromJson(net.sf.json.JSONObject)
     */
    public RefUpdate(JSONObject json) {
        this.fromJson(json);
    }

    @Override
    public void fromJson(JSONObject json) {
// Path: src/main/java/com/sonymobile/tools/gerrit/gerritevents/dto/GerritEventKeys.java
// public static final String PROJECT = "project";
// 
// Path: src/main/java/com/sonymobile/tools/gerrit/gerritevents/dto/GerritEventKeys.java
// public static final String REFNAME = "refName";
// 
// Path: src/main/java/com/sonymobile/tools/gerrit/gerritevents/dto/GerritEventKeys.java
// public static final String OLDREV = "oldRev";
// 
// Path: src/main/java/com/sonymobile/tools/gerrit/gerritevents/dto/GerritEventKeys.java
// public static final String NEWREV = "newRev";


// Path: src/main/java/com/sonymobile/tools/gerrit/gerritevents/dto/attr/RefUpdate.java
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.NEWREV;
import com.sonymobile.tools.gerrit.gerritevents.dto.GerritJsonDTO;
import static com.sonymobile.tools.gerrit.gerritevents.GerritJsonEventFactory.getString;
import net.sf.json.JSONObject;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.PROJECT;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.REFNAME;
import static com.sonymobile.tools.gerrit.gerritevents.dto.GerritEventKeys.OLDREV;

/*
 *  The MIT License
 *
 *  Copyright 2012 Hewlett-Packard Development Company, L.P.
 *
 *  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.attr;



/**
 * Represents a Gerrit JSON Reference Updated DTO.
 * @author James E. Blair &lt;jeblair@hp.com&gt;
 */
public class RefUpdate implements GerritJsonDTO {

    private static final String REFS_HEADS = "refs/heads/";
    /**
     * Project path in Gerrit.
     */
    private String project;
    /**
     * Ref name within project.
     */
    private String refName;
    /**
     * Old revision at ref.
     */
    private String oldRev;
    /**
     * New revision at ref.
     */
    private String newRev;

    /**
     * Default constructor.
     */
    public RefUpdate() {
    }

    /**
     * Constructor that fills with data directly.
     * @param json the JSON Object with corresponding data.
     * @see #fromJson(net.sf.json.JSONObject)
     */
    public RefUpdate(JSONObject json) {
        this.fromJson(json);
    }

    @Override
    public void fromJson(JSONObject json) {
        project = getString(json, PROJECT);