package nu.studer.gradle.rocker;

import org.gradle.api.Project;

import java.util.Objects;

final class RockerVersion {

    private static final String PROJECT_PROPERTY = "rockerVersion";
    private static final String DEFAULT = "1.2.2";

    private final String versionString;

    private RockerVersion(String versionString) {
        this.versionString = versionString;
    }

    static void applyDefaultVersion(Project project) {
        project.getExtensions().getExtraProperties().set(PROJECT_PROPERTY, DEFAULT);
    }

    static RockerVersion fromProject(Project project) {
        return from(Objects.requireNonNull(project.getExtensions().getExtraProperties().get(PROJECT_PROPERTY)).toString());
    }

    private static RockerVersion from(String versionString) {
        return new RockerVersion(versionString);
    }

    String asString() {
        return versionString;
    }

}

@@ -232,11 +232,11 @@
  %221.
-2.2
+3.0
 %22;%0A%0A

Set Rocker default version to 1.3.0