prince-of-versions/src/main/java/co/infinum/princeofversions/helpers/parsers/JsonVersionConfigParser.java
public VersionContext parse(JSONObject data) throws JSONException {
        Version currentVersion = Version.valueOf(this.currentVersion.getVersionString());
        Version minVersion = extractMinimumVersion(data);
        Version latestVersion = extractLatestVersion(data);
        Map<String, String> metadata = extractMetadata(data);
        String notificationType = extractNotificationType(data);
        int minimumVersionMinSdk = extractMinumumVersionMinSdk(data);
        int newMinSdk = extractNewMinSdk(data);

        VersionContext versionContext;

        if (minVersion != null && latestVersion != null) {
            versionContext = new VersionContext(
                    this.currentVersion,
                    new VersionContext.Version(minVersion.toString()),
                    currentVersion.lessThan(minVersion),
                    new VersionContext.UpdateContext(new VersionContext.Version(latestVersion.toString()), notificationType,
                            newMinSdk),
                    currentVersion.lessThan(latestVersion),
                    minimumVersionMinSdk
            );
        } else if (latestVersion != null) {
            versionContext = new VersionContext(
                    this.currentVersion,
                    null,
                    false,
                    new VersionContext.UpdateContext(new VersionContext.Version(latestVersion.toString()), notificationType),
                    currentVersion.lessThan(latestVersion),
                    minimumVersionMinSdk
            );
        } else if (minVersion != null) {
            versionContext = new VersionContext(
                    this.currentVersion,
                    new VersionContext.Version(minVersion.toString()),
                    currentVersion.lessThan(minVersion)
            );
        } else {
            throw new com.github.zafarkhaja.semver.ParseException("Both min and latest versions are null!");
        }

        versionContext.setMetadata(metadata);

        return versionContext;
    }
/**
     * Starts parsing from root JSON object representing update configuration content.
     *
     * @param data Root object from configuration.
     * @return VersionContext holder containing all parsed data.
     * @throws JSONException if error while parsing JSON occurred.
     */
Starts parsing from root JSON object representing update configuration content.
@param data Root object from configuration.
@return VersionContext holder containing all parsed data.
@throws JSONException if error while parsing JSON occurred.
Starts parsing from root JSON object representing update configuration content . @param data Root object from configuration . @return VersionContext holder containing all parsed data . @throws JSONException if error while parsing JSON occurred .
public VersionContext parse(JSONObject data) throws JSONException {
        Version currentVersion = Version.valueOf(this.currentVersion.getVersionString());
        Version minVersion = extractMinimumVersion(data);
        Version latestVersion = extractLatestVersion(data);
        Map<String, String> metadata = extractMetadata(data);
        String notificationType = extractNotificationType(data);
        int minimumVersionMinSdk = extractMinumumVersionMinSdk(data);
        int newMinSdk = extractNewMinSdk(data);
        VersionContext versionContext;
        if (minVersion != null && latestVersion != null) {
            versionContext = new VersionContext(
                    this.currentVersion,
                    new VersionContext.Version(minVersion.toString()),
                    currentVersion.lessThan(minVersion),
                    new VersionContext.UpdateContext(new VersionContext.Version(latestVersion.toString()), notificationType,
                            newMinSdk),
                    currentVersion.lessThan(latestVersion),
                    minimumVersionMinSdk
            );
        } else if (latestVersion != null) {
            versionContext = new VersionContext(
                    this.currentVersion,
                    null,
                    false,
                    new VersionContext.UpdateContext(new VersionContext.Version(latestVersion.toString()), notificationType),
                    currentVersion.lessThan(latestVersion),
                    minimumVersionMinSdk
            );
        } else if (minVersion != null) {
            versionContext = new VersionContext(
                    this.currentVersion,
                    new VersionContext.Version(minVersion.toString()),
                    currentVersion.lessThan(minVersion)
            );
        } else {
            throw new com.github.zafarkhaja.semver.ParseException("Both min and latest versions are null!");
        }
        versionContext.setMetadata(metadata);
        return versionContext;
    }
public VersionContext parse ( JSONObject data ) throws JSONException { Version currentVersion = Version . valueOf ( this . currentVersion . getVersionString ( ) ) ; Version minVersion = extractMinimumVersion ( data ) ; Version latestVersion = extractLatestVersion ( data ) ; Map < String , String > metadata = extractMetadata ( data ) ; String notificationType = extractNotificationType ( data ) ; int minimumVersionMinSdk = extractMinumumVersionMinSdk ( data ) ; int newMinSdk = extractNewMinSdk ( data ) ; VersionContext versionContext ; if ( minVersion != null && latestVersion != null ) { versionContext = new VersionContext ( this . currentVersion , new VersionContext . Version ( minVersion . toString ( ) ) , currentVersion . lessThan ( minVersion ) , new VersionContext . UpdateContext ( new VersionContext . Version ( latestVersion . toString ( ) ) , notificationType , newMinSdk ) , currentVersion . lessThan ( latestVersion ) , minimumVersionMinSdk ) ; } else if ( latestVersion != null ) { versionContext = new VersionContext ( this . currentVersion , null , false , new VersionContext . UpdateContext ( new VersionContext . Version ( latestVersion . toString ( ) ) , notificationType ) , currentVersion . lessThan ( latestVersion ) , minimumVersionMinSdk ) ; } else if ( minVersion != null ) { versionContext = new VersionContext ( this . currentVersion , new VersionContext . Version ( minVersion . toString ( ) ) , currentVersion . lessThan ( minVersion ) ) ; } else { throw new com . github . zafarkhaja . semver . ParseException ( "Both min and latest versions are null!" ) ; } versionContext . setMetadata ( metadata ) ; return versionContext ; }
Starts parsing from root JSON object representing update configuration content.
Starts parsing from root JSON object representing update configuration content .