package com.dropbox.core;

import com.dropbox.core.util.IOUtil;
import com.dropbox.core.util.StringUtil;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.regex.Pattern;

/*>>> import checkers.nullness.quals.Nullable; */

public class DbxSdkVersion
{
    public static final String Version;
    static {
        Version = loadVersion();
    }

    private static final String ResourceName = "/com/dropbox/core/sdk-version.txt";

    private static final class LoadException extends Exception {
        private static final long serialVersionUID = 0L;

        public LoadException(/*@Nullable*/String message) {
            super(message);
        }
    }

    private static String loadLineFromResource()
        throws LoadException
    {
        try {
            InputStream in = DbxSdkVersion.class.getResourceAsStream(ResourceName);
            if (in == null) throw new LoadException("Not found.");
            try {
                BufferedReader bin = new BufferedReader(IOUtil.utf8Reader(in));
                String version = bin.readLine();
                if (version == null) throw new LoadException("No lines.");
                String secondLine = bin.readLine();
                if (secondLine != null) throw new LoadException("Found more than one line.  Second line: " + StringUtil.jq(secondLine));
                return version;
            }
            finally {
                IOUtil.closeInput(in);
            }
        }
        catch (IOException ex) {
            throw new LoadException(ex.getMessage());
        }
    }

    private static String loadVersion()
    {
        try {
            String version = loadLineFromResource();

            Pattern versionRegex = Pattern.compile("[0-9]+(?:\\.[0-9]+)*(?:-[-_A-Za-z0-9]+)?");
            if (!versionRegex.matcher(version).matches()) {
                throw new LoadException("Text doesn't follow expected pattern: " + StringUtil.jq(version));
            }

            return version;
        }
        catch (LoadException ex) {
            throw new RuntimeException("Error loading version from resource \"sdk-version.txt\": " + ex.getMessage());
        }
    }
}

package com.dropbox.core;

/*>>> import checkers.nullness.quals.Nullable; */

public class DbxSdkVersion
{
    public static final String Version;
    static {
        Version = loadVersion();
    }


    private static String loadVersion()
    {
        return "3.0.11"; //TODO: figure out a consistent way to generate it.
    }
}

Replace the `sqk-version.txt` with hard coded version.
Replace the `sqk-version.txt` with hard coded version.
