// Path: src/main/java/com/treasuredata/client/TDClientException.java
// public class TDClientException
//         extends RuntimeException
// {
//     /**
//      * Used for showing detailed error message
//      */
//     public static enum ErrorType
//     {
//         // Configuration error
//         INVALID_CONFIGURATION,
//         INVALID_INPUT,
//         // HTTP error
//         AUTHENTICATION_FAILURE,
//         TARGET_NOT_FOUND,
//         TARGET_ALREADY_EXISTS,
//         SERVER_ERROR,
//         CLIENT_ERROR,
//         // Proxy error
//         PROXY_AUTHENTICATION_FAILURE,
//         // Request handling error
//         INTERRUPTED,
//         REQUEST_TIMEOUT,
//         SSL_ERROR,
//         EXECUTION_FAILURE,
//         UNEXPECTED_RESPONSE_CODE,
//         INVALID_JSON_RESPONSE,
//         SOCKET_ERROR;
//     }
// 
//     private final ErrorType errorType;
//     private final Optional<Exception> rootCause;
// 
//     private static final String formatErrorMessage(ErrorType errorType, String message, Optional<Exception> cause)
//     {
//         String rootCauseErrorMessage = cause.isPresent() ? " The root cause: " + cause.get().getMessage() : "";
//         return String.format("[%s] %s%s", errorType.name(), message != null ? message : "", rootCauseErrorMessage);
//     }
// 
//     public TDClientException(ErrorType errorType, String message, Optional<Exception> cause)
//     {
//         super(formatErrorMessage(errorType, message, cause), cause.orNull());
//         checkNotNull(errorType, "errorType is null");
//         checkNotNull(cause, "cause is null");
//         this.errorType = errorType;
//         this.rootCause = cause;
//     }
// 
//     public TDClientException(ErrorType errorType, String message, Exception cause)
//     {
//         this(errorType, message, Optional.of(cause));
//     }
// 
//     public TDClientException(ErrorType errorType, Exception cause)
//     {
//         this(errorType, cause.getMessage(), Optional.of(cause));
//     }
// 
//     public TDClientException(ErrorType errorType, String message)
//     {
//         this(errorType, message, Optional.<Exception>absent());
//     }
// 
//     public ErrorType getErrorType()
//     {
//         return this.errorType;
//     }
// 
//     public Optional<Exception> getRootCause()
//     {
//         return rootCause;
//     }
// }


import com.google.common.base.Optional;
import com.treasuredata.client.TDClientException;
        return this;
    }

    public TDSavedQueryBuilder setPriority(int priority)
    {
        this.priority = Optional.of(priority);
        return this;
    }

    public TDSavedQueryBuilder setRetryLimit(int retryLimit)
    {
        this.retryLimit = Optional.of(retryLimit);
        return this;
    }

    public TDSavedQueryBuilder setResult(String result)
    {
        this.result = Optional.of(result);
        return this;
    }

    public TDSavedQueryBuilder setEngineVersion(TDJob.EngineVersion engineVersion)
    {
        this.engineVersion = Optional.fromNullable(engineVersion);
        return this;
    }

    private static <T> void checkPresence(Optional<T> opt, String errorMessage)
    {
        if (!opt.isPresent()) {
// Path: src/main/java/com/treasuredata/client/TDClientException.java
// public class TDClientException
//         extends RuntimeException
// {
//     /**
//      * Used for showing detailed error message
//      */
//     public static enum ErrorType
//     {
//         // Configuration error
//         INVALID_CONFIGURATION,
//         INVALID_INPUT,
//         // HTTP error
//         AUTHENTICATION_FAILURE,
//         TARGET_NOT_FOUND,
//         TARGET_ALREADY_EXISTS,
//         SERVER_ERROR,
//         CLIENT_ERROR,
//         // Proxy error
//         PROXY_AUTHENTICATION_FAILURE,
//         // Request handling error
//         INTERRUPTED,
//         REQUEST_TIMEOUT,
//         SSL_ERROR,
//         EXECUTION_FAILURE,
//         UNEXPECTED_RESPONSE_CODE,
//         INVALID_JSON_RESPONSE,
//         SOCKET_ERROR;
//     }
// 
//     private final ErrorType errorType;
//     private final Optional<Exception> rootCause;
// 
//     private static final String formatErrorMessage(ErrorType errorType, String message, Optional<Exception> cause)
//     {
//         String rootCauseErrorMessage = cause.isPresent() ? " The root cause: " + cause.get().getMessage() : "";
//         return String.format("[%s] %s%s", errorType.name(), message != null ? message : "", rootCauseErrorMessage);
//     }
// 
//     public TDClientException(ErrorType errorType, String message, Optional<Exception> cause)
//     {
//         super(formatErrorMessage(errorType, message, cause), cause.orNull());
//         checkNotNull(errorType, "errorType is null");
//         checkNotNull(cause, "cause is null");
//         this.errorType = errorType;
//         this.rootCause = cause;
//     }
// 
//     public TDClientException(ErrorType errorType, String message, Exception cause)
//     {
//         this(errorType, message, Optional.of(cause));
//     }
// 
//     public TDClientException(ErrorType errorType, Exception cause)
//     {
//         this(errorType, cause.getMessage(), Optional.of(cause));
//     }
// 
//     public TDClientException(ErrorType errorType, String message)
//     {
//         this(errorType, message, Optional.<Exception>absent());
//     }
// 
//     public ErrorType getErrorType()
//     {
//         return this.errorType;
//     }
// 
//     public Optional<Exception> getRootCause()
//     {
//         return rootCause;
//     }
// }


// Path: src/main/java/com/treasuredata/client/model/TDSavedQueryBuilder.java
import com.google.common.base.Optional;
import com.treasuredata.client.TDClientException;

        return this;
    }

    public TDSavedQueryBuilder setPriority(int priority)
    {
        this.priority = Optional.of(priority);
        return this;
    }

    public TDSavedQueryBuilder setRetryLimit(int retryLimit)
    {
        this.retryLimit = Optional.of(retryLimit);
        return this;
    }

    public TDSavedQueryBuilder setResult(String result)
    {
        this.result = Optional.of(result);
        return this;
    }

    public TDSavedQueryBuilder setEngineVersion(TDJob.EngineVersion engineVersion)
    {
        this.engineVersion = Optional.fromNullable(engineVersion);
        return this;
    }

    private static <T> void checkPresence(Optional<T> opt, String errorMessage)
    {
        if (!opt.isPresent()) {
            throw new TDClientException(TDClientException.ErrorType.INVALID_INPUT, errorMessage);