// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Commit.java
// public class Commit implements Serializable {
// 
//     private String id;
//     private String displayId;
//     private String authorName;
//     private String authorEmail;
//     private long authorTimestamp;
//     private String message;
//     private List<MinimalCommit> parentsIds;
// 
//     private Commit() {
//     }
// 
//     public Commit(String id, String displayId, String authorName, String authorEmail, long authorTimestamp, String message, List<MinimalCommit> parentsIds) {
//         this.id = id;
//         this.displayId = displayId;
//         this.authorName = authorName;
//         this.authorEmail = authorEmail;
//         this.authorTimestamp = authorTimestamp;
//         this.message = message;
//         this.parentsIds = ImmutableList.copyOf(parentsIds);
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public String getDisplayId() {
//         return displayId;
//     }
// 
//     public String getAuthorName() {
//         return authorName;
//     }
// 
//     public String getAuthorEmail() {
//         return authorEmail;
//     }
// 
//     public long getAuthorTimestamp() {
//         return authorTimestamp;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     public List<MinimalCommit> getParentsIds() {
//         return parentsIds;
//     }
// 
//     @Override
//     public String toString() {
//         return "Commit{" +
//                 "id='" + id + '\'' +
//                 ", displayId='" + displayId + '\'' +
//                 ", authorName='" + authorName + '\'' +
//                 ", authorEmail='" + authorEmail + '\'' +
//                 ", authorTimestamp=" + authorTimestamp +
//                 ", message='" + message + '\'' +
//                 ", parentsIds=" + parentsIds +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         Commit changeSet = (Commit) o;
//         return Objects.equals(authorTimestamp, changeSet.authorTimestamp) &&
//                 Objects.equals(id, changeSet.id) &&
//                 Objects.equals(displayId, changeSet.displayId) &&
//                 Objects.equals(authorName, changeSet.authorName) &&
//                 Objects.equals(authorEmail, changeSet.authorEmail) &&
//                 Objects.equals(message, changeSet.message) &&
//                 Objects.equals(parentsIds, changeSet.parentsIds);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(id, displayId, authorName, authorEmail, authorTimestamp, message, parentsIds);
//     }
// 
// }
// 
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
//     return new ListParser<>(elementParser);
// }
// 
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, MinimalCommit> minimalCommitParser() {
//     return MINIMAL_COMMIT_PARSER;
// }


import com.ccreanga.bitbucket.rest.client.model.Commit;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.minimalCommitParser;
/*
 *
 *  *
 *  * 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 CommitParser implements Function<JsonElement, Commit> {
    @Override
    public Commit apply(JsonElement jsonElement) {

        if (jsonElement == null || !jsonElement.isJsonObject()) {
            return null;
        }
        JsonObject json = jsonElement.getAsJsonObject();

        return new Commit(
                json.get("id").getAsString(),
                json.get("displayId").getAsString(),
                json.get("author").getAsJsonObject().get("name").getAsString(),
                json.get("author").getAsJsonObject().get("emailAddress").getAsString(),
                json.get("authorTimestamp").getAsLong(),
                json.get("message").getAsString(),
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/model/Commit.java
// public class Commit implements Serializable {
// 
//     private String id;
//     private String displayId;
//     private String authorName;
//     private String authorEmail;
//     private long authorTimestamp;
//     private String message;
//     private List<MinimalCommit> parentsIds;
// 
//     private Commit() {
//     }
// 
//     public Commit(String id, String displayId, String authorName, String authorEmail, long authorTimestamp, String message, List<MinimalCommit> parentsIds) {
//         this.id = id;
//         this.displayId = displayId;
//         this.authorName = authorName;
//         this.authorEmail = authorEmail;
//         this.authorTimestamp = authorTimestamp;
//         this.message = message;
//         this.parentsIds = ImmutableList.copyOf(parentsIds);
//     }
// 
//     public String getId() {
//         return id;
//     }
// 
//     public String getDisplayId() {
//         return displayId;
//     }
// 
//     public String getAuthorName() {
//         return authorName;
//     }
// 
//     public String getAuthorEmail() {
//         return authorEmail;
//     }
// 
//     public long getAuthorTimestamp() {
//         return authorTimestamp;
//     }
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     public List<MinimalCommit> getParentsIds() {
//         return parentsIds;
//     }
// 
//     @Override
//     public String toString() {
//         return "Commit{" +
//                 "id='" + id + '\'' +
//                 ", displayId='" + displayId + '\'' +
//                 ", authorName='" + authorName + '\'' +
//                 ", authorEmail='" + authorEmail + '\'' +
//                 ", authorTimestamp=" + authorTimestamp +
//                 ", message='" + message + '\'' +
//                 ", parentsIds=" + parentsIds +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         Commit changeSet = (Commit) o;
//         return Objects.equals(authorTimestamp, changeSet.authorTimestamp) &&
//                 Objects.equals(id, changeSet.id) &&
//                 Objects.equals(displayId, changeSet.displayId) &&
//                 Objects.equals(authorName, changeSet.authorName) &&
//                 Objects.equals(authorEmail, changeSet.authorEmail) &&
//                 Objects.equals(message, changeSet.message) &&
//                 Objects.equals(parentsIds, changeSet.parentsIds);
//     }
// 
//     @Override
//     public int hashCode() {
//         return Objects.hash(id, displayId, authorName, authorEmail, authorTimestamp, message, parentsIds);
//     }
// 
// }
// 
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static <T> Function<JsonElement, List<T>> listParser(Function<JsonElement, T> elementParser) {
//     return new ListParser<>(elementParser);
// }
// 
// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/Parsers.java
// public static Function<JsonElement, MinimalCommit> minimalCommitParser() {
//     return MINIMAL_COMMIT_PARSER;
// }


// Path: src/main/java/com/ccreanga/bitbucket/rest/client/http/responseparsers/CommitParser.java
import com.ccreanga.bitbucket.rest.client.model.Commit;
import java.util.function.Function;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.listParser;
import static com.ccreanga.bitbucket.rest.client.http.responseparsers.Parsers.minimalCommitParser;

/*
 *
 *  *
 *  * 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 CommitParser implements Function<JsonElement, Commit> {
    @Override
    public Commit apply(JsonElement jsonElement) {

        if (jsonElement == null || !jsonElement.isJsonObject()) {
            return null;
        }
        JsonObject json = jsonElement.getAsJsonObject();

        return new Commit(
                json.get("id").getAsString(),
                json.get("displayId").getAsString(),
                json.get("author").getAsJsonObject().get("name").getAsString(),
                json.get("author").getAsJsonObject().get("emailAddress").getAsString(),
                json.get("authorTimestamp").getAsLong(),
                json.get("message").getAsString(),
                listParser(minimalCommitParser()).apply(json.get("parents"))