/**
   * Maps to a sub-region of [0..1]
   *
   * @param min the lower bound
   * @param max the upper bound
   * @return a transformation from [0..1] to [min..max]
   */
  public static TimeModifier sub(float min, float max) {
    Preconditions.checkArgument(min >= 0f);
    Preconditions.checkArgument(max > min);
    Preconditions.checkArgument(max <= 1f);

    float range = max - min;
    return v -> min + (v * range);
  }
 @VisibleForTesting
 RefreshingOAuth2CredentialsInterceptor(
     ExecutorService scheduler,
     OAuth2Credentials credentials,
     RetryOptions retryOptions,
     Logger logger) {
   this.executor = Preconditions.checkNotNull(scheduler);
   this.credentials = Preconditions.checkNotNull(credentials);
   this.retryOptions = Preconditions.checkNotNull(retryOptions);
   this.logger = Preconditions.checkNotNull(logger);
 }
 /**
  * Create a request for the method "getNewsClassification".
  *
  * <p>This request holds the parameters needed by the the extractApi server. After setting any
  * optional parameters, call the {@link GetNewsClassification#execute()} method to invoke the
  * remote operation.
  *
  * <p>{@link GetNewsClassification#initialize(com.google.api.client.googleapis.
  * services.AbstractGoogleClientRequest)} must be called to initialize this instance immediately
  * after invoking the constructor.
  *
  * @param content
  * @param title
  * @since 1.13
  */
 protected GetNewsClassification(java.lang.String content, java.lang.String title) {
   super(
       ExtractApi.this,
       "GET",
       REST_PATH,
       null,
       com.example.backend.extractApi.model.NewsClassification.class);
   this.content =
       com.google.api.client.util.Preconditions.checkNotNull(
           content, "Required parameter content must be specified.");
   this.title =
       com.google.api.client.util.Preconditions.checkNotNull(
           title, "Required parameter title must be specified.");
 }
 /**
  * Parses the namespaces declared on the current element into the namespace dictionary.
  *
  * @param parser XML pull parser
  * @param namespaceDictionary namespace dictionary
  */
 private static void parseNamespacesForElement(
     XmlPullParser parser, XmlNamespaceDictionary namespaceDictionary)
     throws XmlPullParserException {
   int eventType = parser.getEventType();
   Preconditions.checkState(
       eventType == XmlPullParser.START_TAG,
       "expected start of XML element, but got something else (event type %s)",
       eventType);
   int depth = parser.getDepth();
   int nsStart = parser.getNamespaceCount(depth - 1);
   int nsEnd = parser.getNamespaceCount(depth);
   for (int i = nsStart; i < nsEnd; i++) {
     String namespace = parser.getNamespaceUri(i);
     // if namespace isn't already in our dictionary, add it now
     if (namespaceDictionary.getAliasForUri(namespace) == null) {
       String prefix = parser.getNamespacePrefix(i);
       String originalAlias = prefix == null ? "" : prefix;
       // find an available alias
       String alias = originalAlias;
       int suffix = 1;
       while (namespaceDictionary.getUriForAlias(alias) != null) {
         suffix++;
         alias = originalAlias + suffix;
       }
       namespaceDictionary.set(alias, namespace);
     }
   }
 }
 public Smartcanvas(
     HttpTransport httpTransport,
     JsonFactory jsonFactory,
     String clientId,
     String clientSecret,
     boolean useSandbox)
     throws JoseException {
   super();
   this.transport =
       Preconditions.checkNotNull(
           httpTransport, "Required parameter httpTransport must be specified.");
   this.jsonFactory =
       Preconditions.checkNotNull(
           jsonFactory, "Required parameter jsonFactory must be specified.");
   this.authInitializer = new SmartcanvasAuthentication(clientId, clientSecret, null);
   this.useSandbox = useSandbox;
 }
 // Note: Leave this static initializer at the top of the file.
 static {
   com.google.api.client.util.Preconditions.checkState(
       com.google.api.client.googleapis.GoogleUtils.MAJOR_VERSION == 1
           && com.google.api.client.googleapis.GoogleUtils.MINOR_VERSION >= 15,
       "You are currently running with version %s of google-api-client. "
           + "You need at least version 1.15 of google-api-client to run version "
           + "1.16.0-rc of the employeeendpoint library.",
       com.google.api.client.googleapis.GoogleUtils.VERSION);
 }
 /**
  * Create a request for the method "get".
  *
  * <p>This request holds the parameters needed by the the litterTypeApi server. After setting
  * any optional parameters, call the {@link Get#execute()} method to invoke the remote
  * operation.
  *
  * <p>{@link
  * Get#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)} must
  * be called to initialize this instance immediately after invoking the constructor.
  *
  * @param id
  * @since 1.13
  */
 protected Get(java.lang.Long id) {
   super(
       LitterTypeApi.this,
       "GET",
       REST_PATH,
       null,
       uk.ac.bristol.littermappingtool.backend.litterTypeApi.model.LitterType.class);
   this.id =
       com.google.api.client.util.Preconditions.checkNotNull(
           id, "Required parameter id must be specified.");
 }
 /**
  * Create a request for the method "getEmployee".
  *
  * <p>This request holds the parameters needed by the the employeeendpoint server. After setting
  * any optional parameters, call the {@link GetEmployee#execute()} method to invoke the remote
  * operation.
  *
  * <p>{@link
  * GetEmployee#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
  * must be called to initialize this instance immediately after invoking the constructor.
  *
  * @param email
  * @since 1.13
  */
 protected GetEmployee(java.lang.String email) {
   super(
       Employeeendpoint.this,
       "GET",
       REST_PATH,
       null,
       com.blw.employeeendpoint.model.Employee.class);
   this.email =
       com.google.api.client.util.Preconditions.checkNotNull(
           email, "Required parameter email must be specified.");
 }
 /**
  * Create a request for the method "getQuote".
  *
  * <p>This request holds the parameters needed by the the quoteendpoint server. After setting
  * any optional parameters, call the {@link GetQuote#execute()} method to invoke the remote
  * operation.
  *
  * <p>{@link
  * GetQuote#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
  * must be called to initialize this instance immediately after invoking the constructor.
  *
  * @param id
  * @since 1.13
  */
 protected GetQuote(java.lang.Long id) {
   super(
       Quoteendpoint.this,
       "GET",
       REST_PATH,
       null,
       com.protips6.entity.quoteendpoint.model.Quote.class);
   this.id =
       com.google.api.client.util.Preconditions.checkNotNull(
           id, "Required parameter id must be specified.");
 }
 /**
  * Create a request for the method "getOferta".
  *
  * <p>This request holds the parameters needed by the the ofertaendpoint server. After setting
  * any optional parameters, call the {@link GetOferta#execute()} method to invoke the remote
  * operation.
  *
  * <p>{@link
  * GetOferta#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
  * must be called to initialize this instance immediately after invoking the constructor.
  *
  * @param id
  * @since 1.13
  */
 protected GetOferta(java.lang.Long id) {
   super(
       Ofertaendpoint.this,
       "GET",
       REST_PATH,
       null,
       com.jtristan.reservarestaurantev2.entidades.ofertaendpoint.model.Oferta.class);
   this.id =
       com.google.api.client.util.Preconditions.checkNotNull(
           id, "Required parameter id must be specified.");
 }
 /**
  * Create a request for the method "greetings.getGreeting".
  *
  * <p>This request holds the parameters needed by the the gear server. After setting any
  * optional parameters, call the {@link GetGreeting#execute()} method to invoke the remote
  * operation.
  *
  * <p>{@link
  * GetGreeting#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
  * must be called to initialize this instance immediately after invoking the constructor.
  *
  * @param id
  * @since 1.13
  */
 protected GetGreeting(java.lang.Integer id) {
   super(
       Gear.this,
       "GET",
       REST_PATH,
       null,
       com.appspot.backendgear_1121.gear.model.GearBackendGreeting.class);
   this.id =
       com.google.api.client.util.Preconditions.checkNotNull(
           id, "Required parameter id must be specified.");
 }
Exemple #12
0
 /**
  * Create a request for the method "grabJoke".
  *
  * <p>This request holds the parameters needed by the the jokeApi server. After setting any
  * optional parameters, call the {@link GrabJoke#execute()} method to invoke the remote
  * operation.
  *
  * <p>{@link
  * GrabJoke#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
  * must be called to initialize this instance immediately after invoking the constructor.
  *
  * @param joke
  * @since 1.13
  */
 protected GrabJoke(java.lang.String joke) {
   super(
       JokeApi.this,
       "POST",
       REST_PATH,
       null,
       com.udacity.gradle.builditbigger.backend.jokeApi.model.Joke.class);
   this.joke =
       com.google.api.client.util.Preconditions.checkNotNull(
           joke, "Required parameter joke must be specified.");
 }
Exemple #13
0
 /**
  * Create a request for the method "getNode".
  *
  * <p>This request holds the parameters needed by the the nodeendpoint server. After setting any
  * optional parameters, call the {@link GetNode#execute()} method to invoke the remote
  * operation.
  *
  * <p>{@link
  * GetNode#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
  * must be called to initialize this instance immediately after invoking the constructor.
  *
  * @param id
  * @since 1.13
  */
 protected GetNode(java.lang.Long id) {
   super(
       Nodeendpoint.this,
       "GET",
       REST_PATH,
       null,
       edu.vt.bmac.gpstracker.nodeendpoint.model.Node.class);
   this.id =
       com.google.api.client.util.Preconditions.checkNotNull(
           id, "Required parameter id must be specified.");
 }
 /**
  * Create a request for the method "extractUrl".
  *
  * <p>This request holds the parameters needed by the the extractApi server. After setting any
  * optional parameters, call the {@link ExtractUrl#execute()} method to invoke the remote
  * operation.
  *
  * <p>{@link
  * ExtractUrl#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
  * must be called to initialize this instance immediately after invoking the constructor.
  *
  * @param url
  * @since 1.13
  */
 protected ExtractUrl(java.lang.String url) {
   super(
       ExtractApi.this,
       "GET",
       REST_PATH,
       null,
       com.example.backend.extractApi.model.ExtractedNewsObject.class);
   this.url =
       com.google.api.client.util.Preconditions.checkNotNull(
           url, "Required parameter url must be specified.");
 }
 /**
  * Create a request for the method "getLunchDate".
  *
  * <p>This request holds the parameters needed by the the lunchdateendpoint server. After
  * setting any optional parameters, call the {@link GetLunchDate#execute()} method to invoke the
  * remote operation.
  *
  * <p>{@link
  * GetLunchDate#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
  * must be called to initialize this instance immediately after invoking the constructor.
  *
  * @param id
  * @since 1.13
  */
 protected GetLunchDate(java.lang.Long id) {
   super(
       Lunchdateendpoint.this,
       "GET",
       REST_PATH,
       null,
       com.linkedlunchbuddy.lunchdateendpoint.model.LunchDate.class);
   this.id =
       com.google.api.client.util.Preconditions.checkNotNull(
           id, "Required parameter id must be specified.");
 }
 /**
  * Create a request for the method "getGossipMessage".
  *
  * <p>This request holds the parameters needed by the the gossipmessageendpoint server. After
  * setting any optional parameters, call the {@link GetGossipMessage#execute()} method to invoke
  * the remote operation.
  *
  * <p>{@link GetGossipMessage#initialize(com.google.api.client.googleapis.s
  * ervices.AbstractGoogleClientRequest)} must be called to initialize this instance immediately
  * after invoking the constructor.
  *
  * @param id
  * @since 1.13
  */
 protected GetGossipMessage(java.lang.Long id) {
   super(
       Gossipmessageendpoint.this,
       "GET",
       REST_PATH,
       null,
       com.horsepowerx.gossip.gossipmessageendpoint.model.GossipMessage.class);
   this.id =
       com.google.api.client.util.Preconditions.checkNotNull(
           id, "Required parameter id must be specified.");
 }
Exemple #17
0
 /**
  * Create a request for the method "getJoke".
  *
  * <p>This request holds the parameters needed by the the jokeApi server. After setting any
  * optional parameters, call the {@link GetJoke#execute()} method to invoke the remote
  * operation.
  *
  * <p>{@link
  * GetJoke#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
  * must be called to initialize this instance immediately after invoking the constructor.
  *
  * @param id
  * @since 1.13
  */
 protected GetJoke(java.lang.Long id) {
   super(
       JokeApi.this,
       "GET",
       REST_PATH,
       null,
       com.udacity.gradle.builditbigger.backend.jokeApi.model.Joke.class);
   this.id =
       com.google.api.client.util.Preconditions.checkNotNull(
           id, "Required parameter id must be specified.");
 }
 /**
  * Create a request for the method "greetings.multiply".
  *
  * <p>This request holds the parameters needed by the the gear server. After setting any
  * optional parameters, call the {@link Multiply#execute()} method to invoke the remote
  * operation.
  *
  * <p>{@link
  * Multiply#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
  * must be called to initialize this instance immediately after invoking the constructor.
  *
  * @param times
  * @param content the {@link com.appspot.backendgear_1121.gear.model.GearBackendGreeting}
  * @since 1.13
  */
 protected Multiply(
     java.lang.Integer times,
     com.appspot.backendgear_1121.gear.model.GearBackendGreeting content) {
   super(
       Gear.this,
       "POST",
       REST_PATH,
       content,
       com.appspot.backendgear_1121.gear.model.GearBackendGreeting.class);
   this.times =
       com.google.api.client.util.Preconditions.checkNotNull(
           times, "Required parameter times must be specified.");
 }
 public HeaderCacheElement(AccessToken token) {
   this.exception = null;
   this.header = "Bearer " + token.getTokenValue();
   Date expirationTime = token.getExpirationTime();
   if (expirationTime != null) {
     long tokenExpiresTime = expirationTime.getTime();
     this.staleTimeMs = tokenExpiresTime - TOKEN_STALENESS_MS;
     // Block until refresh at this point.
     this.expiresTimeMs = tokenExpiresTime - TOKEN_EXPIRES_MS;
     Preconditions.checkState(staleTimeMs < expiresTimeMs);
   } else {
     this.staleTimeMs = null;
     this.expiresTimeMs = null;
   }
 }
 static GoogleClientSecrets getClientCredential() throws IOException {
   if (clientSecrets == null) {
     clientSecrets =
         GoogleClientSecrets.load(
             JSON_FACTORY,
             new InputStreamReader(
                 ServiceUtils.class.getResourceAsStream("/client_secrets.json")));
     Preconditions.checkArgument(
         !clientSecrets.getDetails().getClientId().startsWith("Enter ")
             && !clientSecrets.getDetails().getClientSecret().startsWith("Enter "),
         "Enter Client ID and Secret from https://code.google.com/apis/console/?api=bigquery "
             + "into bigquery-appengine-sample/src/main/resources/client_secrets.json");
   }
   return clientSecrets;
 }
 /**
  * Create a request for the method "updateEmployee".
  *
  * <p>This request holds the parameters needed by the the employeeendpoint server. After setting
  * any optional parameters, call the {@link UpdateEmployee#execute()} method to invoke the
  * remote operation.
  *
  * <p>{@link UpdateEmployee#initialize(com.google.api.client.googleapis.services.Abstr
  * actGoogleClientRequest)} must be called to initialize this instance immediately after
  * invoking the constructor.
  *
  * @param firstName
  * @param lastName
  * @param phoneNumber
  * @param cellNumber
  * @param email
  * @param idNumber
  * @param country
  * @param city
  * @since 1.13
  */
 protected UpdateEmployee(
     java.lang.String firstName,
     java.lang.String lastName,
     java.lang.String phoneNumber,
     java.lang.String cellNumber,
     java.lang.String email,
     java.lang.String idNumber,
     java.lang.String country,
     java.lang.String city) {
   super(
       Employeeendpoint.this,
       "PUT",
       REST_PATH,
       null,
       com.blw.employeeendpoint.model.Employee.class);
   this.firstName =
       com.google.api.client.util.Preconditions.checkNotNull(
           firstName, "Required parameter firstName must be specified.");
   this.lastName =
       com.google.api.client.util.Preconditions.checkNotNull(
           lastName, "Required parameter lastName must be specified.");
   this.phoneNumber =
       com.google.api.client.util.Preconditions.checkNotNull(
           phoneNumber, "Required parameter phoneNumber must be specified.");
   this.cellNumber =
       com.google.api.client.util.Preconditions.checkNotNull(
           cellNumber, "Required parameter cellNumber must be specified.");
   this.email =
       com.google.api.client.util.Preconditions.checkNotNull(
           email, "Required parameter email must be specified.");
   this.idNumber =
       com.google.api.client.util.Preconditions.checkNotNull(
           idNumber, "Required parameter idNumber must be specified.");
   this.country =
       com.google.api.client.util.Preconditions.checkNotNull(
           country, "Required parameter country must be specified.");
   this.city =
       com.google.api.client.util.Preconditions.checkNotNull(
           city, "Required parameter city must be specified.");
 }
Exemple #22
0
 private void initializeParser(JsonParser paramJsonParser) throws IOException {
   boolean bool = true;
   if (wrapperKeys.isEmpty()) ;
   while (true) {
     return;
     try {
       if ((paramJsonParser.skipToKey(wrapperKeys) != null)
           && (paramJsonParser.getCurrentToken() != JsonToken.END_OBJECT)) ;
       while (true) {
         Preconditions.checkArgument(
             bool, "wrapper key(s) not found: %s", new Object[] {wrapperKeys});
         if (0 == 0) break;
         paramJsonParser.close();
         return;
         bool = false;
       }
     } finally {
       if (1 != 0) paramJsonParser.close();
     }
   }
 }
 /**
  * Create a request for the method "removeEmployee".
  *
  * <p>This request holds the parameters needed by the the employeeendpoint server. After setting
  * any optional parameters, call the {@link RemoveEmployee#execute()} method to invoke the
  * remote operation.
  *
  * <p>{@link RemoveEmployee#initialize(com.google.api.client.googleapis.services.Abstr
  * actGoogleClientRequest)} must be called to initialize this instance immediately after
  * invoking the constructor.
  *
  * @param email
  * @since 1.13
  */
 protected RemoveEmployee(java.lang.String email) {
   super(Employeeendpoint.this, "DELETE", REST_PATH, null, Void.class);
   this.email =
       com.google.api.client.util.Preconditions.checkNotNull(
           email, "Required parameter email must be specified.");
 }
 /**
  * increases the speed by factor <code>times</codes> and restarts from 0.
  * @param times the (positive) multiplication factor
  * @return a mapping function
  */
 public static TimeModifier multiply(float times) {
   Preconditions.checkArgument(times > 0f);
   return v -> (v * times) % 1f;
 }
 /**
  * Always returns the same constant value
  *
  * @param constant the constant value
  * @return a mapping function
  */
 public static TimeModifier constant(float constant) {
   Preconditions.checkArgument(constant >= 0 && constant <= 1);
   return v -> constant;
 }
 /**
  * Create a request for the method "removeGossipMessage".
  *
  * <p>This request holds the parameters needed by the the gossipmessageendpoint server. After
  * setting any optional parameters, call the {@link RemoveGossipMessage#execute()} method to
  * invoke the remote operation.
  *
  * <p>{@link RemoveGossipMessage#initialize(com.google.api.client.go
  * ogleapis.services.AbstractGoogleClientRequest)} must be called to initialize this instance
  * immediately after invoking the constructor.
  *
  * @param id
  * @since 1.13
  */
 protected RemoveGossipMessage(java.lang.Long id) {
   super(Gossipmessageendpoint.this, "DELETE", REST_PATH, null, Void.class);
   this.id =
       com.google.api.client.util.Preconditions.checkNotNull(
           id, "Required parameter id must be specified.");
 }
Exemple #27
0
 public Builder(JsonFactory paramJsonFactory) {
   jsonFactory = ((JsonFactory) Preconditions.checkNotNull(paramJsonFactory));
 }
 /**
  * Returns the HTTP content length or {@code -1} for unknown.
  *
  * <p>Default value is {@code -1}.
  *
  * @since 1.5
  */
 public MockHttpContent setLength(long length) {
   Preconditions.checkArgument(length >= -1);
   this.length = length;
   return this;
 }
 /**
  * Sets the HTTP content.
  *
  * <p>Default value is an empty byte array.
  *
  * @since 1.5
  */
 public MockHttpContent setContent(byte[] content) {
   this.content = Preconditions.checkNotNull(content);
   return this;
 }
 /**
  * Create a request for the method "messagingEndpoint.sendMessage".
  *
  * <p>This request holds the parameters needed by the the messaging server. After setting any
  * optional parameters, call the {@link SendMessage#execute()} method to invoke the remote
  * operation.
  *
  * <p>{@link
  * SendMessage#initialize(com.google.api.client.googleapis.services.AbstractGoogleClientRequest)}
  * must be called to initialize this instance immediately after invoking the constructor.
  *
  * @param message
  * @since 1.13
  */
 protected SendMessage(java.lang.String message) {
   super(Messaging.this, "POST", REST_PATH, null, Void.class);
   this.message =
       com.google.api.client.util.Preconditions.checkNotNull(
           message, "Required parameter message must be specified.");
 }