package com.raychenon.licensedroid;

import android.os.Parcel;
import android.os.Parcelable;

import com.raychenon.licensedroid.license.LicenseInfos;

/**
 * @author Raymond Chenon
 */
public class OpenSource implements Parcelable {

    @SuppressWarnings("unused")
    public static final Parcelable.Creator<OpenSource> CREATOR = new Parcelable.Creator<OpenSource>() {
        @Override
        public OpenSource createFromParcel(Parcel in) {
            return new OpenSource(in);
        }

        @Override
        public OpenSource[] newArray(int size) {
            return new OpenSource[size];
        }
    };
    // internal
    public final boolean isLicenseText;
    private final String libraryName;
    private final String author;
    private String licenseText;
    private LicenseInfos license;
    // optional
    private String libraryVersion;

    public OpenSource(Builder builder) {
        this.libraryName = builder.libraryName;
        this.author = builder.author;
        this.license = builder.license;
        this.licenseText = builder.licenseText;
        this.libraryVersion = builder.libraryVersion;

        isLicenseText = licenseText != null;
    }

    protected OpenSource(Parcel in) {
        isLicenseText = in.readByte() != 0x00;
        libraryName = in.readString();
        author = in.readString();
        licenseText = in.readString();
        license = (LicenseInfos) in.readValue(LicenseInfos.class.getClassLoader());
        libraryVersion = in.readString();
    }

    public String getProjectName() {
        return libraryName;
    }

    public String getAuthor() {
        return author;
    }

    public String getLicenseText() {
        return licenseText;
    }

    public LicenseInfos getLicense() {
        return license;
    }

    public String getVersion() {
        return libraryVersion;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeByte((byte) (isLicenseText ? 0x01 : 0x00));
        dest.writeString(libraryName);
        dest.writeString(author);
        dest.writeString(licenseText);
        dest.writeSerializable(license);
        dest.writeString(libraryVersion);
    }

    public static class Builder {
        private String libraryName;
        private String author;
        private String licenseText;
        private LicenseInfos license;
        // optional
        private String libraryVersion;

        public Builder(final String libraryName, final String author, final String licenseText) {
            this.libraryName = libraryName;
            this.author = author;
            this.licenseText = licenseText;
        }

        public Builder(final String libraryName, final String author, final LicenseInfos license) {
            this.libraryName = libraryName;
            this.author = author;
            this.license = license;
        }

        public Builder withVersion(final String libraryVersion) {
            this.libraryVersion = libraryVersion;
            return this;
        }

        public OpenSource build() {
            return new OpenSource(this);
        }

    }
}

@@ -851,24 +851,55 @@
 raryVersion;
+%0A    private String gitRepoUrl;
 %0A%0A    public
@@ -1148,32 +1148,78 @@
 .libraryVersion;
+%0A        this.gitRepoUrl = builder.gitRepoUrl;
 %0A%0A        isLice
@@ -1575,24 +1575,62 @@
 adString();%0A
+        gitRepoUrl = in.readString();%0A
     %7D%0A%0A    p
@@ -1963,32 +1963,101 @@
 Version;%0A    %7D%0A%0A
+    public String getGitRepoUrl()%7B%0A        return gitRepoUrl;%0A    %7D%0A%0A
     @Override%0A  
@@ -2438,24 +2438,62 @@
 ryVersion);%0A
+        dest.writeString(gitRepoUrl);%0A
     %7D%0A%0A    p
@@ -2720,16 +2720,51 @@
 Version;
+%0A        private String gitRepoUrl;
 %0A%0A      
@@ -3275,24 +3275,24 @@
 yVersion) %7B%0A
-
             
@@ -3357,32 +3357,174 @@
 his;%0A        %7D%0A%0A
+        public Builder withGitRepoUrl(final String gitRepoUrl)%7B%0A            this.gitRepoUrl = gitRepoUrl;%0A            return this;%0A        %7D%0A%0A
         public O

add gitRepoUrl