/*
 * Copyright 2016 LinkedIn Corp.
 *
 * 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.linkedin.gradle.python.extension;

import java.io.Serializable;

public class PythonVersion implements Serializable {

    private final String version;

    public PythonVersion(String version) {
        this.version = version;
    }

    /**
     * @return The exact version of Python this project uses, such as '2.7.11'.
     */
    public String getPythonVersion() {
        return version;
    }

    /**
     * @return The short version of Python this project uses, such as '2.7'.
     */
    public String getPythonMajorMinor() {
        String[] split = version.split("\\.");
        return String.format("%s.%s", split[0], split[1]);
    }

    /**
     * @return The major version of Python this project uses, such as '2'.
     */
    public String getPythonMajor() {
        return version.split("\\.")[0];
    }
}

@@ -835,32 +835,168 @@
 ion;%0A    %7D%0A%0A
+    private String getVersionPart(int position) %7B%0A        String%5B%5D parts = version.split(%22%5C%5C.%22);%0A        return parts%5Bposition%5D;%0A    %7D%0A%0A
     /**%0A
      * @retu
@@ -975,32 +975,32 @@
 %0A    %7D%0A%0A    /**%0A
-
      * @return T
@@ -1280,55 +1280,8 @@
 ) %7B%0A
-        String%5B%5D split = version.split(%22%5C%5C.%22);%0A
     
@@ -1318,26 +1318,44 @@
 s%22, 
-split%5B0%5D, split%5B1%5D
+getVersionPart(0), getVersionPart(1)
 );%0A 
@@ -1507,31 +1507,364 @@
 urn 
-version.split(%22%5C%5C.%22)%5B0%5D
+getVersionPart(0);%0A    %7D%0A%0A    /**%0A     * @return The minor version of Python this project uses, such as '7'.%0A     */%0A    public String getPythonMinor() %7B%0A        return getVersionPart(1);%0A    %7D%0A%0A    /**%0A     * @return The patch version of Python this project uses, such as '11'.%0A     */%0A    public String getPythonPatch() %7B%0A        return getVersionPart(2)
 ;%0A  

Add access to individual PythonVersion parts.