// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestBranch.java
// public class PullRequestBranch  implements Serializable {
// 
//     private String id;
//     private String repositorySlug;
//     private String repositoryName;
//     private String projectKey;
// 
//     private PullRequestBranch() {
//     }
// 
//     public PullRequestBranch(String id, String repositorySlug, String repositoryName, String projectKey) {
//         this.id = id;
//         this.repositorySlug = repositorySlug;
//         this.repositoryName = repositoryName;
//         this.projectKey = projectKey;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public String getRepositorySlug() {
//         return repositorySlug;
//     }
// 
//     public String getRepositoryName() {
//         return repositoryName;
//     }
// 
//     public String getProjectKey() {
//         return projectKey;
//     }
// 
//     @Override
//     public String toString() {
//         return "PullRequestBranch{" +
//                 "id='" + id + '\'' +
//                 ", repositorySlug='" + repositorySlug + '\'' +
//                 ", repositoryName='" + repositoryName + '\'' +
//                 ", projectKey='" + projectKey + '\'' +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         PullRequestBranch that = (PullRequestBranch) o;
//         return Objects.equals(id, that.id) &&
//                 Objects.equals(repositorySlug, that.repositorySlug) &&
//                 Objects.equals(repositoryName, that.repositoryName) &&
//                 Objects.equals(projectKey, that.projectKey);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(id, repositorySlug, repositoryName, projectKey);
//     }
// }
// 
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
//     JsonElement element = json.get(name);
//     if ((element == null) || (element.isJsonNull()))
//         return null;
//     return element.getAsString();
// }


import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestBranch;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;
/*
 *
 *  *
 *  * Licensed under the Apache License, Version 2.0 (the "License");
 *  * you may not use this file except in compliance with the License.
 *  * You may obtain a copy of the License at
 *  *
 *  * http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  * Unless required by applicable law or agreed to in writing, software
 *  * distributed under the License is distributed on an "AS IS" BASIS,
 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  * See the License for the specific language governing permissions and
 *  * limitations under the License.
 *
 */

package com.ccreanga.bitbucket.rest.client.http.responseparsers;



public class PullRequestBranchParser implements Function<JsonElement, PullRequestBranch> {
    @Override
    public PullRequestBranch apply(JsonElement json) {
        if (json == null || !json.isJsonObject()) {
            return null;
        }
        JsonObject jsonObject = json.getAsJsonObject();
        JsonObject repository = jsonObject.getAsJsonObject("repository");
        JsonObject project = repository.getAsJsonObject("project");
        return new PullRequestBranch(
                jsonObject.get("id").getAsString(),
                repository.get("slug").getAsString(),
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/pull/PullRequestBranch.java
// public class PullRequestBranch  implements Serializable {
// 
//     private String id;
//     private String repositorySlug;
//     private String repositoryName;
//     private String projectKey;
// 
//     private PullRequestBranch() {
//     }
// 
//     public PullRequestBranch(String id, String repositorySlug, String repositoryName, String projectKey) {
//         this.id = id;
//         this.repositorySlug = repositorySlug;
//         this.repositoryName = repositoryName;
//         this.projectKey = projectKey;
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public String getRepositorySlug() {
//         return repositorySlug;
//     }
// 
//     public String getRepositoryName() {
//         return repositoryName;
//     }
// 
//     public String getProjectKey() {
//         return projectKey;
//     }
// 
//     @Override
//     public String toString() {
//         return "PullRequestBranch{" +
//                 "id='" + id + '\'' +
//                 ", repositorySlug='" + repositorySlug + '\'' +
//                 ", repositoryName='" + repositoryName + '\'' +
//                 ", projectKey='" + projectKey + '\'' +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         PullRequestBranch that = (PullRequestBranch) o;
//         return Objects.equals(id, that.id) &&
//                 Objects.equals(repositorySlug, that.repositorySlug) &&
//                 Objects.equals(repositoryName, that.repositoryName) &&
//                 Objects.equals(projectKey, that.projectKey);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(id, repositorySlug, repositoryName, projectKey);
//     }
// }
// 
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/ParserUtil.java
// public static String optionalJsonString(JsonObject json, String name) {
//     JsonElement element = json.get(name);
//     if ((element == null) || (element.isJsonNull()))
//         return null;
//     return element.getAsString();
// }


// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/PullRequestBranchParser.java
import com.ccreanga.bitbucket.rest.client.model.pull.PullRequestBranch;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.ParserUtil.optionalJsonString;

/*
 *
 *  *
 *  * Licensed under the Apache License, Version 2.0 (the "License");
 *  * you may not use this file except in compliance with the License.
 *  * You may obtain a copy of the License at
 *  *
 *  * http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  * Unless required by applicable law or agreed to in writing, software
 *  * distributed under the License is distributed on an "AS IS" BASIS,
 *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  * See the License for the specific language governing permissions and
 *  * limitations under the License.
 *
 */

package com.ccreanga.bitbucket.rest.client.http.responseparsers;



public class PullRequestBranchParser implements Function<JsonElement, PullRequestBranch> {
    @Override
    public PullRequestBranch apply(JsonElement json) {
        if (json == null || !json.isJsonObject()) {
            return null;
        }
        JsonObject jsonObject = json.getAsJsonObject();
        JsonObject repository = jsonObject.getAsJsonObject("repository");
        JsonObject project = repository.getAsJsonObject("project");
        return new PullRequestBranch(
                jsonObject.get("id").getAsString(),
                repository.get("slug").getAsString(),
                optionalJsonString(repository, "name"),