index
int64 | repo_id
string | file_path
string | content
string |
|---|---|---|---|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/RateLimitExecutorService.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal;
import ai.nextbillion.maps.internal.ratelimiter.RateLimiter;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** Rate Limit Policy for Google Maps Web Services APIs. */
public class RateLimitExecutorService implements ExecutorService, Runnable {
private static final Logger LOG =
LoggerFactory.getLogger(RateLimitExecutorService.class.getName());
private static final int DEFAULT_QUERIES_PER_SECOND = 50;
// It's important we set Ok's second arg to threadFactory(.., true) to ensure the threads are
// killed when the app exits. For synchronous requests this is ideal but it means any async
// requests still pending after termination will be killed.
private final ExecutorService delegate =
new ThreadPoolExecutor(
Runtime.getRuntime().availableProcessors(),
Integer.MAX_VALUE,
60,
TimeUnit.SECONDS,
new SynchronousQueue<Runnable>(),
threadFactory("Rate Limited Dispatcher", true));
private final BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();
private final RateLimiter rateLimiter =
RateLimiter.create(DEFAULT_QUERIES_PER_SECOND, 1, TimeUnit.SECONDS);
final Thread delayThread;
public RateLimitExecutorService() {
setQueriesPerSecond(DEFAULT_QUERIES_PER_SECOND);
delayThread = new Thread(this);
delayThread.setDaemon(true);
delayThread.setName("RateLimitExecutorDelayThread");
delayThread.start();
}
public void setQueriesPerSecond(int maxQps) {
this.rateLimiter.setRate(maxQps);
}
/** Main loop. */
@Override
public void run() {
try {
while (!delegate.isShutdown()) {
this.rateLimiter.acquire();
Runnable r = queue.take();
if (!delegate.isShutdown()) {
delegate.execute(r);
}
}
} catch (InterruptedException ie) {
LOG.info("Interrupted", ie);
}
}
private static ThreadFactory threadFactory(final String name, final boolean daemon) {
return new ThreadFactory() {
@Override
public Thread newThread(Runnable runnable) {
Thread result = new Thread(runnable, name);
result.setDaemon(daemon);
return result;
}
};
}
@Override
public void execute(Runnable runnable) {
queue.add(runnable);
}
@Override
public void shutdown() {
delegate.shutdown();
// we need this to break out of queue.take()
execute(
new Runnable() {
@Override
public void run() {
// do nothing
}
});
}
// Everything below here is straight delegation.
@Override
public List<Runnable> shutdownNow() {
List<Runnable> tasks = delegate.shutdownNow();
// we need this to break out of queue.take()
execute(
new Runnable() {
@Override
public void run() {
// do nothing
}
});
return tasks;
}
@Override
public boolean isShutdown() {
return delegate.isShutdown();
}
@Override
public boolean isTerminated() {
return delegate.isTerminated();
}
@Override
public boolean awaitTermination(long l, TimeUnit timeUnit) throws InterruptedException {
return delegate.awaitTermination(l, timeUnit);
}
@Override
public <T> Future<T> submit(Callable<T> tCallable) {
return delegate.submit(tCallable);
}
@Override
public <T> Future<T> submit(Runnable runnable, T t) {
return delegate.submit(runnable, t);
}
@Override
public Future<?> submit(Runnable runnable) {
return delegate.submit(runnable);
}
@Override
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> callables)
throws InterruptedException {
return delegate.invokeAll(callables);
}
@Override
public <T> List<Future<T>> invokeAll(
Collection<? extends Callable<T>> callables, long l, TimeUnit timeUnit)
throws InterruptedException {
return delegate.invokeAll(callables, l, timeUnit);
}
@Override
public <T> T invokeAny(Collection<? extends Callable<T>> callables)
throws InterruptedException, ExecutionException {
return delegate.invokeAny(callables);
}
@Override
public <T> T invokeAny(Collection<? extends Callable<T>> callables, long l, TimeUnit timeUnit)
throws InterruptedException, ExecutionException, TimeoutException {
return delegate.invokeAny(callables, l, timeUnit);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/SafeEnumAdapter.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A {@link com.google.gson.TypeAdapter} that maps case-insensitive values to an enum type. If the
* value is not found, an UNKNOWN value is returned, and logged. This allows the server to return
* values this client doesn't yet know about.
*
* @param <E> the enum type to map values to.
*/
public class SafeEnumAdapter<E extends Enum<E>> extends TypeAdapter<E> {
private static final Logger LOG = LoggerFactory.getLogger(SafeEnumAdapter.class.getName());
private final Class<E> clazz;
private final E unknownValue;
/** @param unknownValue the value to return if the value cannot be found. */
public SafeEnumAdapter(E unknownValue) {
if (unknownValue == null) throw new IllegalArgumentException();
this.unknownValue = unknownValue;
this.clazz = unknownValue.getDeclaringClass();
}
@Override
public void write(JsonWriter out, E value) throws IOException {
throw new UnsupportedOperationException("Unimplemented method");
}
@Override
public E read(JsonReader reader) throws IOException {
if (reader.peek() == JsonToken.NULL) {
reader.nextNull();
return null;
}
String value = reader.nextString();
try {
return Enum.valueOf(clazz, value.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException iae) {
LOG.warn("Unknown type for enum {}: '{}'", clazz.getName(), value);
return unknownValue;
}
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/StringJoin.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal;
import ai.nextbillion.maps.DirectionsApi;
/** Utility class to join strings. */
public class StringJoin {
/**
* Marker Interface to enable the URL Value enums in {@link DirectionsApi} to be string joinable.
*/
public interface UrlValue {
/** @return the object, represented as a URL value (not URL encoded). */
String toUrlValue();
}
private StringJoin() {}
public static String join(char delim, String... parts) {
return join(new String(new char[] {delim}), parts);
}
public static String join(CharSequence delim, String... parts) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < parts.length; i++) {
if (i != 0) {
result.append(delim);
}
result.append(parts[i]);
}
return result.toString();
}
public static String join(char delim, Object... parts) {
return join(new String(new char[] {delim}), parts);
}
public static String join(CharSequence delim, Object... parts) {
StringBuilder result = new StringBuilder();
for (int i = 0; i < parts.length; i++) {
if (i != 0) {
result.append(delim);
}
result.append(parts[i]);
}
return result.toString();
}
public static String join(char delim, UrlValue... parts) {
String[] strings = new String[parts.length];
int i = 0;
for (UrlValue part : parts) {
strings[i++] = part.toUrlValue();
}
return join(delim, strings);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/UrlSigner.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import okio.ByteString;
/**
* Utility class for supporting Maps for Work Digital signatures.
*
* <p>See <a
* href="https://developers.google.com/maps/documentation/directions/get-api-key#client-id">Using a
* client ID</a> for more detail on this protocol.
*/
public class UrlSigner {
private static final String ALGORITHM_HMAC_SHA1 = "HmacSHA1";
private final Mac mac;
public UrlSigner(final String keyString) throws NoSuchAlgorithmException, InvalidKeyException {
// Convert from URL-safe base64 to regular base64.
String base64 = keyString.replace('-', '+').replace('_', '/');
ByteString decodedKey = ByteString.decodeBase64(base64);
if (decodedKey == null) {
// NOTE: don't log the exception, in case some of the private key leaks to an end-user.
throw new IllegalArgumentException("Private key is invalid.");
}
mac = Mac.getInstance(ALGORITHM_HMAC_SHA1);
mac.init(new SecretKeySpec(decodedKey.toByteArray(), ALGORITHM_HMAC_SHA1));
}
public String getSignature(String path) {
byte[] digest = getMac().doFinal(path.getBytes(UTF_8));
return ByteString.of(digest).base64().replace('+', '-').replace('/', '_');
}
private Mac getMac() {
// Mac is not thread-safe. Requires a new clone for each signature.
try {
return (Mac) mac.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException(e);
}
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/ZonedDateTimeAdapter.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
/**
* This class handles conversion from JSON to {@link ZonedDateTime}s.
*
* <p>Please see <a
* href="https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/TypeAdapter.html">TypeAdapter</a>
* for more detail.
*/
public class ZonedDateTimeAdapter extends TypeAdapter<ZonedDateTime> {
/**
* Read a Time object from a Directions API result and convert it to a {@link ZonedDateTime}.
*
* <p>We are expecting to receive something akin to the following:
*
* <pre>
* {
* "text" : "4:27pm",
* "time_zone" : "Australia/Sydney",
* "value" : 1406528829
* }
* </pre>
*/
@Override
public ZonedDateTime read(JsonReader reader) throws IOException {
if (reader.peek() == JsonToken.NULL) {
reader.nextNull();
return null;
}
String timeZoneId = "";
long secondsSinceEpoch = 0L;
reader.beginObject();
while (reader.hasNext()) {
String name = reader.nextName();
if (name.equals("text")) {
// Ignore the human-readable rendering.
reader.nextString();
} else if (name.equals("time_zone")) {
timeZoneId = reader.nextString();
} else if (name.equals("value")) {
secondsSinceEpoch = reader.nextLong();
}
}
reader.endObject();
return ZonedDateTime.ofInstant(
Instant.ofEpochMilli(secondsSinceEpoch * 1000), ZoneId.of(timeZoneId));
}
/** This method is not implemented. */
@Override
public void write(JsonWriter writer, ZonedDateTime value) throws IOException {
throw new UnsupportedOperationException("Unimplemented method");
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/ratelimiter/LongMath.java
|
/*
* Copyright (C) 2012 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* Copyright 2017 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal.ratelimiter;
/**
* A class for arithmetic on values of type {@code long}.
*
* <p>This is a minimal port of Google Guava's com.google.common.math.LongMath, just sufficient to
* implement the ratelimiter classes.
*/
public final class LongMath {
private LongMath() {}
@SuppressWarnings("ShortCircuitBoolean")
public static long saturatedAdd(long a, long b) {
long naiveSum = a + b;
if ((a ^ b) < 0 | (a ^ naiveSum) >= 0) {
// If a and b have different signs or a has the same sign as the result then there was no
// overflow, return.
return naiveSum;
}
// we did over/under flow, if the sign is negative we should return MAX otherwise MIN
return Long.MAX_VALUE + ((naiveSum >>> (Long.SIZE - 1)) ^ 1);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/ratelimiter/Platform.java
|
/*
* Copyright (C) 2009 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* Copyright 2017 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal.ratelimiter;
import java.util.Locale;
/**
* Methods factored out so that they can be emulated differently in GWT.
*
* <p>This is a minimal port of Google Guava's com.google.common.base.Platform, sufficient to
* implement the ratelimiter classes.
*
* @author Jesse Wilson
*/
final class Platform {
private Platform() {}
/** Calls {@link System#nanoTime()}. */
static long systemNanoTime() {
return System.nanoTime();
}
static String formatCompact4Digits(double value) {
return String.format(Locale.ROOT, "%.4g", value);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/ratelimiter/Preconditions.java
|
/*
* Copyright (C) 2012 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* Copyright 2017 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal.ratelimiter;
/**
* Static convenience methods that help a method or constructor check whether it was invoked
* correctly (that is, whether its <i>preconditions</i> were met).
*
* <p>This is a minimal port of Google Guava's com.google.common.base.Preconditions necessary to
* implement the ratelimiter classes.
*/
public final class Preconditions {
private Preconditions() {}
public static void checkArgument(
boolean expression, String errorMessageTemplate, Object... errorMessageArgs) {
if (!expression) {
throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs));
}
}
public static <T> T checkNotNull(T reference) {
if (reference == null) {
throw new NullPointerException();
}
return reference;
}
public static <T> T checkNotNull(T reference, Object errorMessage) {
if (reference == null) {
throw new NullPointerException(String.valueOf(errorMessage));
}
return reference;
}
public static void checkState(boolean expression, Object errorMessage) {
if (!expression) {
throw new IllegalStateException(String.valueOf(errorMessage));
}
}
static String format(String template, Object... args) {
template = String.valueOf(template); // null -> "null"
args = args == null ? new Object[] {"(Object[])null"} : args;
// start substituting the arguments into the '%s' placeholders
StringBuilder builder = new StringBuilder(template.length() + 16 * args.length);
int templateStart = 0;
int i = 0;
while (i < args.length) {
int placeholderStart = template.indexOf("%s", templateStart);
if (placeholderStart == -1) {
break;
}
builder.append(template, templateStart, placeholderStart);
builder.append(args[i++]);
templateStart = placeholderStart + 2;
}
builder.append(template, templateStart, template.length());
// if we run out of placeholders, append the extra args in square braces
if (i < args.length) {
builder.append(" [");
builder.append(args[i++]);
while (i < args.length) {
builder.append(", ");
builder.append(args[i++]);
}
builder.append(']');
}
return builder.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/ratelimiter/RateLimiter.java
|
/*
* Copyright (C) 2012 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* Copyright 2017 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal.ratelimiter;
import static ai.nextbillion.maps.internal.ratelimiter.Preconditions.checkArgument;
import static ai.nextbillion.maps.internal.ratelimiter.Preconditions.checkNotNull;
import static java.lang.Math.max;
import static java.util.concurrent.TimeUnit.MICROSECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import ai.nextbillion.maps.internal.ratelimiter.SmoothRateLimiter.SmoothBursty;
import ai.nextbillion.maps.internal.ratelimiter.SmoothRateLimiter.SmoothWarmingUp;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
/**
* A rate limiter. Conceptually, a rate limiter distributes permits at a configurable rate. Each
* {@link #acquire()} blocks if necessary until a permit is available, and then takes it. Once
* acquired, permits need not be released.
*
* <p>Rate limiters are often used to restrict the rate at which some physical or logical resource
* is accessed. This is in contrast to {@link java.util.concurrent.Semaphore} which restricts the
* number of concurrent accesses instead of the rate (note though that concurrency and rate are
* closely related, e.g. see <a href="http://en.wikipedia.org/wiki/Little%27s_law">Little's
* Law</a>).
*
* <p>A {@code RateLimiter} is defined primarily by the rate at which permits are issued. Absent
* additional configuration, permits will be distributed at a fixed rate, defined in terms of
* permits per second. Permits will be distributed smoothly, with the delay between individual
* permits being adjusted to ensure that the configured rate is maintained.
*
* <p>It is possible to configure a {@code RateLimiter} to have a warmup period during which time
* the permits issued each second steadily increases until it hits the stable rate.
*
* <p>As an example, imagine that we have a list of tasks to execute, but we don't want to submit
* more than 2 per second:
*
* <pre>{@code
* final RateLimiter rateLimiter = RateLimiter.create(2.0); // rate is "2 permits per second"
* void submitTasks(List<Runnable> tasks, Executor executor) {
* for (Runnable task : tasks) {
* rateLimiter.acquire(); // may wait
* executor.execute(task);
* }
* }
* }</pre>
*
* <p>As another example, imagine that we produce a stream of data, and we want to cap it at 5kb per
* second. This could be accomplished by requiring a permit per byte, and specifying a rate of 5000
* permits per second:
*
* <pre>{@code
* final RateLimiter rateLimiter = RateLimiter.create(5000.0); // rate = 5000 permits per second
* void submitPacket(byte[] packet) {
* rateLimiter.acquire(packet.length);
* networkService.send(packet);
* }
* }</pre>
*
* <p>It is important to note that the number of permits requested <i>never</i> affects the
* throttling of the request itself (an invocation to {@code acquire(1)} and an invocation to {@code
* acquire(1000)} will result in exactly the same throttling, if any), but it affects the throttling
* of the <i>next</i> request. I.e., if an expensive task arrives at an idle RateLimiter, it will be
* granted immediately, but it is the <i>next</i> request that will experience extra throttling,
* thus paying for the cost of the expensive task.
*
* <p>Note: {@code RateLimiter} does not provide fairness guarantees.
*
* @author Dimitris Andreou
* @since 13.0
*/
public abstract class RateLimiter {
public static RateLimiter create(double permitsPerSecond) {
/*
* The default RateLimiter configuration can save the unused permits of up to one second. This
* is to avoid unnecessary stalls in situations like this: A RateLimiter of 1qps, and 4 threads,
* all calling acquire() at these moments:
*
* T0 at 0 seconds
* T1 at 1.05 seconds
* T2 at 2 seconds
* T3 at 3 seconds
*
* Due to the slight delay of T1, T2 would have to sleep till 2.05 seconds, and T3 would also
* have to sleep till 3.05 seconds.
*/
return create(permitsPerSecond, SleepingStopwatch.createFromSystemTimer());
}
static RateLimiter create(double permitsPerSecond, SleepingStopwatch stopwatch) {
RateLimiter rateLimiter = new SmoothBursty(stopwatch, 1.0 /* maxBurstSeconds */);
rateLimiter.setRate(permitsPerSecond);
return rateLimiter;
}
public static RateLimiter create(double permitsPerSecond, long warmupPeriod, TimeUnit unit) {
checkArgument(warmupPeriod >= 0, "warmupPeriod must not be negative: %s", warmupPeriod);
return create(
permitsPerSecond, warmupPeriod, unit, 3.0, SleepingStopwatch.createFromSystemTimer());
}
static RateLimiter create(
double permitsPerSecond,
long warmupPeriod,
TimeUnit unit,
double coldFactor,
SleepingStopwatch stopwatch) {
RateLimiter rateLimiter = new SmoothWarmingUp(stopwatch, warmupPeriod, unit, coldFactor);
rateLimiter.setRate(permitsPerSecond);
return rateLimiter;
}
/**
* The underlying timer; used both to measure elapsed time and sleep as necessary. A separate
* object to facilitate testing.
*/
private final SleepingStopwatch stopwatch;
// Can't be initialized in the constructor because mocks don't call the constructor.
private volatile Object mutexDoNotUseDirectly;
private Object mutex() {
Object mutex = mutexDoNotUseDirectly;
if (mutex == null) {
synchronized (this) {
mutex = mutexDoNotUseDirectly;
if (mutex == null) {
mutexDoNotUseDirectly = mutex = new Object();
}
}
}
return mutex;
}
RateLimiter(SleepingStopwatch stopwatch) {
this.stopwatch = checkNotNull(stopwatch);
}
/**
* Updates the stable rate of this {@code RateLimiter}, that is, the {@code permitsPerSecond}
* argument provided in the factory method that constructed the {@code RateLimiter}. Currently
* throttled threads will <b>not</b> be awakened as a result of this invocation, thus they do not
* observe the new rate; only subsequent requests will.
*
* <p>Note though that, since each request repays (by waiting, if necessary) the cost of the
* <i>previous</i> request, this means that the very next request after an invocation to {@code
* setRate} will not be affected by the new rate; it will pay the cost of the previous request,
* which is in terms of the previous rate.
*
* <p>The behavior of the {@code RateLimiter} is not modified in any other way, e.g. if the {@code
* RateLimiter} was configured with a warmup period of 20 seconds, it still has a warmup period of
* 20 seconds after this method invocation.
*
* @param permitsPerSecond the new stable rate of this {@code RateLimiter}
* @throws IllegalArgumentException if {@code permitsPerSecond} is negative or zero
*/
public final void setRate(double permitsPerSecond) {
checkArgument(
permitsPerSecond > 0.0 && !Double.isNaN(permitsPerSecond), "rate must be positive");
synchronized (mutex()) {
doSetRate(permitsPerSecond, stopwatch.readMicros());
}
}
abstract void doSetRate(double permitsPerSecond, long nowMicros);
public final double getRate() {
synchronized (mutex()) {
return doGetRate();
}
}
abstract double doGetRate();
/**
* Acquires a single permit from this {@code RateLimiter}, blocking until the request can be
* granted. Tells the amount of time slept, if any.
*
* <p>This method is equivalent to {@code acquire(1)}.
*
* @return time spent sleeping to enforce rate, in seconds; 0.0 if not rate-limited
* @since 16.0 (present in 13.0 with {@code void} return type})
*/
public double acquire() {
return acquire(1);
}
/**
* Acquires the given number of permits from this {@code RateLimiter}, blocking until the request
* can be granted. Tells the amount of time slept, if any.
*
* @param permits the number of permits to acquire
* @return time spent sleeping to enforce rate, in seconds; 0.0 if not rate-limited
* @throws IllegalArgumentException if the requested number of permits is negative or zero
* @since 16.0 (present in 13.0 with {@code void} return type})
*/
public double acquire(int permits) {
long microsToWait = reserve(permits);
stopwatch.sleepMicrosUninterruptibly(microsToWait);
return 1.0 * microsToWait / SECONDS.toMicros(1L);
}
/**
* Reserves the given number of permits from this {@code RateLimiter} for future use, returning
* the number of microseconds until the reservation can be consumed.
*
* @return time in microseconds to wait until the resource can be acquired, never negative
*/
final long reserve(int permits) {
checkPermits(permits);
synchronized (mutex()) {
return reserveAndGetWaitLength(permits, stopwatch.readMicros());
}
}
/**
* Acquires a permit from this {@code RateLimiter} if it can be obtained without exceeding the
* specified {@code timeout}, or returns {@code false} immediately (without waiting) if the permit
* would not have been granted before the timeout expired.
*
* <p>This method is equivalent to {@code tryAcquire(1, timeout, unit)}.
*
* @param timeout the maximum time to wait for the permit. Negative values are treated as zero.
* @param unit the time unit of the timeout argument
* @return {@code true} if the permit was acquired, {@code false} otherwise
* @throws IllegalArgumentException if the requested number of permits is negative or zero
*/
public boolean tryAcquire(long timeout, TimeUnit unit) {
return tryAcquire(1, timeout, unit);
}
/**
* Acquires permits from this {@link RateLimiter} if it can be acquired immediately without delay.
*
* <p>This method is equivalent to {@code tryAcquire(permits, 0, anyUnit)}.
*
* @param permits the number of permits to acquire
* @return {@code true} if the permits were acquired, {@code false} otherwise
* @throws IllegalArgumentException if the requested number of permits is negative or zero
* @since 14.0
*/
public boolean tryAcquire(int permits) {
return tryAcquire(permits, 0, MICROSECONDS);
}
/**
* Acquires a permit from this {@link RateLimiter} if it can be acquired immediately without
* delay.
*
* <p>This method is equivalent to {@code tryAcquire(1)}.
*
* @return {@code true} if the permit was acquired, {@code false} otherwise
* @since 14.0
*/
public boolean tryAcquire() {
return tryAcquire(1, 0, MICROSECONDS);
}
/**
* Acquires the given number of permits from this {@code RateLimiter} if it can be obtained
* without exceeding the specified {@code timeout}, or returns {@code false} immediately (without
* waiting) if the permits would not have been granted before the timeout expired.
*
* @param permits the number of permits to acquire
* @param timeout the maximum time to wait for the permits. Negative values are treated as zero.
* @param unit the time unit of the timeout argument
* @return {@code true} if the permits were acquired, {@code false} otherwise
* @throws IllegalArgumentException if the requested number of permits is negative or zero
*/
public boolean tryAcquire(int permits, long timeout, TimeUnit unit) {
long timeoutMicros = max(unit.toMicros(timeout), 0);
checkPermits(permits);
long microsToWait;
synchronized (mutex()) {
long nowMicros = stopwatch.readMicros();
if (!canAcquire(nowMicros, timeoutMicros)) {
return false;
} else {
microsToWait = reserveAndGetWaitLength(permits, nowMicros);
}
}
stopwatch.sleepMicrosUninterruptibly(microsToWait);
return true;
}
private boolean canAcquire(long nowMicros, long timeoutMicros) {
return queryEarliestAvailable(nowMicros) - timeoutMicros <= nowMicros;
}
/**
* Reserves next ticket and returns the wait time that the caller must wait for.
*
* @return the required wait time, never negative
*/
final long reserveAndGetWaitLength(int permits, long nowMicros) {
long momentAvailable = reserveEarliestAvailable(permits, nowMicros);
return max(momentAvailable - nowMicros, 0);
}
/**
* Returns the earliest time that permits are available (with one caveat).
*
* @return the time that permits are available, or, if permits are available immediately, an
* arbitrary past or present time
*/
abstract long queryEarliestAvailable(long nowMicros);
/**
* Reserves the requested number of permits and returns the time that those permits can be used
* (with one caveat).
*
* @return the time that the permits may be used, or, if the permits may be used immediately, an
* arbitrary past or present time
*/
abstract long reserveEarliestAvailable(int permits, long nowMicros);
@Override
public String toString() {
return String.format(Locale.ROOT, "RateLimiter[stableRate=%3.1fqps]", getRate());
}
abstract static class SleepingStopwatch {
/** Constructor for use by subclasses. */
protected SleepingStopwatch() {}
/*
* We always hold the mutex when calling this.
*/
protected abstract long readMicros();
protected abstract void sleepMicrosUninterruptibly(long micros);
public static SleepingStopwatch createFromSystemTimer() {
return new SleepingStopwatch() {
final Stopwatch stopwatch = Stopwatch.createStarted();
@Override
protected long readMicros() {
return stopwatch.elapsed(MICROSECONDS);
}
@Override
protected void sleepMicrosUninterruptibly(long micros) {
if (micros > 0) {
sleepUninterruptibly(micros, MICROSECONDS);
}
}
};
}
}
private static void checkPermits(int permits) {
checkArgument(permits > 0, "Requested permits (%s) must be positive", permits);
}
/** Invokes {@code unit.}{@link TimeUnit#sleep(long) sleep(sleepFor)} uninterruptibly. */
private static void sleepUninterruptibly(long sleepFor, TimeUnit unit) {
boolean interrupted = false;
try {
long remainingNanos = unit.toNanos(sleepFor);
long end = System.nanoTime() + remainingNanos;
while (true) {
try {
// TimeUnit.sleep() treats negative timeouts just like zero.
NANOSECONDS.sleep(remainingNanos);
return;
} catch (InterruptedException e) {
interrupted = true;
remainingNanos = end - System.nanoTime();
}
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/ratelimiter/SmoothRateLimiter.java
|
/*
* Copyright (C) 2012 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* Copyright 2017 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal.ratelimiter;
import static java.lang.Math.min;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.concurrent.TimeUnit;
abstract class SmoothRateLimiter extends RateLimiter {
/*
* How is the RateLimiter designed, and why?
*
* The primary feature of a RateLimiter is its "stable rate", the maximum rate that is should
* allow at normal conditions. This is enforced by "throttling" incoming requests as needed, i.e.
* compute, for an incoming request, the appropriate throttle time, and make the calling thread
* wait as much.
*
* The simplest way to maintain a rate of QPS is to keep the timestamp of the last granted
* request, and ensure that (1/QPS) seconds have elapsed since then. For example, for a rate of
* QPS=5 (5 tokens per second), if we ensure that a request isn't granted earlier than 200ms after
* the last one, then we achieve the intended rate. If a request comes and the last request was
* granted only 100ms ago, then we wait for another 100ms. At this rate, serving 15 fresh permits
* (i.e. for an acquire(15) request) naturally takes 3 seconds.
*
* It is important to realize that such a RateLimiter has a very superficial memory of the past:
* it only remembers the last request. What if the RateLimiter was unused for a long period of
* time, then a request arrived and was immediately granted? This RateLimiter would immediately
* forget about that past underutilization. This may result in either underutilization or
* overflow, depending on the real world consequences of not using the expected rate.
*
* Past underutilization could mean that excess resources are available. Then, the RateLimiter
* should speed up for a while, to take advantage of these resources. This is important when the
* rate is applied to networking (limiting bandwidth), where past underutilization typically
* translates to "almost empty buffers", which can be filled immediately.
*
* On the other hand, past underutilization could mean that "the server responsible for handling
* the request has become less ready for future requests", i.e. its caches become stale, and
* requests become more likely to trigger expensive operations (a more extreme case of this
* example is when a server has just booted, and it is mostly busy with getting itself up to
* speed).
*
* To deal with such scenarios, we add an extra dimension, that of "past underutilization",
* modeled by "storedPermits" variable. This variable is zero when there is no underutilization,
* and it can grow up to maxStoredPermits, for sufficiently large underutilization. So, the
* requested permits, by an invocation acquire(permits), are served from:
*
* - stored permits (if available)
*
* - fresh permits (for any remaining permits)
*
* How this works is best explained with an example:
*
* For a RateLimiter that produces 1 token per second, every second that goes by with the
* RateLimiter being unused, we increase storedPermits by 1. Say we leave the RateLimiter unused
* for 10 seconds (i.e., we expected a request at time X, but we are at time X + 10 seconds before
* a request actually arrives; this is also related to the point made in the last paragraph), thus
* storedPermits becomes 10.0 (assuming maxStoredPermits >= 10.0). At that point, a request of
* acquire(3) arrives. We serve this request out of storedPermits, and reduce that to 7.0 (how
* this is translated to throttling time is discussed later). Immediately after, assume that an
* acquire(10) request arriving. We serve the request partly from storedPermits, using all the
* remaining 7.0 permits, and the remaining 3.0, we serve them by fresh permits produced by the
* rate limiter.
*
* We already know how much time it takes to serve 3 fresh permits: if the rate is
* "1 token per second", then this will take 3 seconds. But what does it mean to serve 7 stored
* permits? As explained above, there is no unique answer. If we are primarily interested to deal
* with underutilization, then we want stored permits to be given out /faster/ than fresh ones,
* because underutilization = free resources for the taking. If we are primarily interested to
* deal with overflow, then stored permits could be given out /slower/ than fresh ones. Thus, we
* require a (different in each case) function that translates storedPermits to throtting time.
*
* This role is played by storedPermitsToWaitTime(double storedPermits, double permitsToTake). The
* underlying model is a continuous function mapping storedPermits (from 0.0 to maxStoredPermits)
* onto the 1/rate (i.e. intervals) that is effective at the given storedPermits. "storedPermits"
* essentially measure unused time; we spend unused time buying/storing permits. Rate is
* "permits / time", thus "1 / rate = time / permits". Thus, "1/rate" (time / permits) times
* "permits" gives time, i.e., integrals on this function (which is what storedPermitsToWaitTime()
* computes) correspond to minimum intervals between subsequent requests, for the specified number
* of requested permits.
*
* Here is an example of storedPermitsToWaitTime: If storedPermits == 10.0, and we want 3 permits,
* we take them from storedPermits, reducing them to 7.0, and compute the throttling for these as
* a call to storedPermitsToWaitTime(storedPermits = 10.0, permitsToTake = 3.0), which will
* evaluate the integral of the function from 7.0 to 10.0.
*
* Using integrals guarantees that the effect of a single acquire(3) is equivalent to {
* acquire(1); acquire(1); acquire(1); }, or { acquire(2); acquire(1); }, etc, since the integral
* of the function in [7.0, 10.0] is equivalent to the sum of the integrals of [7.0, 8.0], [8.0,
* 9.0], [9.0, 10.0] (and so on), no matter what the function is. This guarantees that we handle
* correctly requests of varying weight (permits), /no matter/ what the actual function is - so we
* can tweak the latter freely. (The only requirement, obviously, is that we can compute its
* integrals).
*
* Note well that if, for this function, we chose a horizontal line, at height of exactly (1/QPS),
* then the effect of the function is non-existent: we serve storedPermits at exactly the same
* cost as fresh ones (1/QPS is the cost for each). We use this trick later.
*
* If we pick a function that goes /below/ that horizontal line, it means that we reduce the area
* of the function, thus time. Thus, the RateLimiter becomes /faster/ after a period of
* underutilization. If, on the other hand, we pick a function that goes /above/ that horizontal
* line, then it means that the area (time) is increased, thus storedPermits are more costly than
* fresh permits, thus the RateLimiter becomes /slower/ after a period of underutilization.
*
* Last, but not least: consider a RateLimiter with rate of 1 permit per second, currently
* completely unused, and an expensive acquire(100) request comes. It would be nonsensical to just
* wait for 100 seconds, and /then/ start the actual task. Why wait without doing anything? A much
* better approach is to /allow/ the request right away (as if it was an acquire(1) request
* instead), and postpone /subsequent/ requests as needed. In this version, we allow starting the
* task immediately, and postpone by 100 seconds future requests, thus we allow for work to get
* done in the meantime instead of waiting idly.
*
* This has important consequences: it means that the RateLimiter doesn't remember the time of the
* _last_ request, but it remembers the (expected) time of the _next_ request. This also enables
* us to tell immediately (see tryAcquire(timeout)) whether a particular timeout is enough to get
* us to the point of the next scheduling time, since we always maintain that. And what we mean by
* "an unused RateLimiter" is also defined by that notion: when we observe that the
* "expected arrival time of the next request" is actually in the past, then the difference (now -
* past) is the amount of time that the RateLimiter was formally unused, and it is that amount of
* time which we translate to storedPermits. (We increase storedPermits with the amount of permits
* that would have been produced in that idle time). So, if rate == 1 permit per second, and
* arrivals come exactly one second after the previous, then storedPermits is _never_ increased --
* we would only increase it for arrivals _later_ than the expected one second.
*/
/**
* This implements the following function where coldInterval = coldFactor * stableInterval.
*
* <pre>
* ^ throttling
* |
* cold + /
* interval | /.
* | / .
* | / . ← "warmup period" is the area of the trapezoid between
* | / . thresholdPermits and maxPermits
* | / .
* | / .
* | / .
* stable +----------/ WARM .
* interval | . UP .
* | . PERIOD.
* | . .
* 0 +----------+-------+--------------→ storedPermits
* 0 thresholdPermits maxPermits
* </pre>
*
* Before going into the details of this particular function, let's keep in mind the basics:
*
* <ol>
* <li>The state of the RateLimiter (storedPermits) is a vertical line in this figure.
* <li>When the RateLimiter is not used, this goes right (up to maxPermits)
* <li>When the RateLimiter is used, this goes left (down to zero), since if we have
* storedPermits, we serve from those first
* <li>When _unused_, we go right at a constant rate! The rate at which we move to the right is
* chosen as maxPermits / warmupPeriod. This ensures that the time it takes to go from 0 to
* maxPermits is equal to warmupPeriod.
* <li>When _used_, the time it takes, as explained in the introductory class note, is equal to
* the integral of our function, between X permits and X-K permits, assuming we want to
* spend K saved permits.
* </ol>
*
* <p>In summary, the time it takes to move to the left (spend K permits), is equal to the area of
* the function of width == K.
*
* <p>Assuming we have saturated demand, the time to go from maxPermits to thresholdPermits is
* equal to warmupPeriod. And the time to go from thresholdPermits to 0 is warmupPeriod/2. (The
* reason that this is warmupPeriod/2 is to maintain the behavior of the original implementation
* where coldFactor was hard coded as 3.)
*
* <p>It remains to calculate thresholdsPermits and maxPermits.
*
* <ul>
* <li>The time to go from thresholdPermits to 0 is equal to the integral of the function
* between 0 and thresholdPermits. This is thresholdPermits * stableIntervals. By (5) it is
* also equal to warmupPeriod/2. Therefore
* <blockquote>
* thresholdPermits = 0.5 * warmupPeriod / stableInterval
* </blockquote>
* <li>The time to go from maxPermits to thresholdPermits is equal to the integral of the
* function between thresholdPermits and maxPermits. This is the area of the pictured
* trapezoid, and it is equal to 0.5 * (stableInterval + coldInterval) * (maxPermits -
* thresholdPermits). It is also equal to warmupPeriod, so
* <blockquote>
* maxPermits = thresholdPermits + 2 * warmupPeriod / (stableInterval + coldInterval)
* </blockquote>
* </ul>
*/
static final class SmoothWarmingUp extends SmoothRateLimiter {
private final long warmupPeriodMicros;
/**
* The slope of the line from the stable interval (when permits == 0), to the cold interval
* (when permits == maxPermits)
*/
private double slope;
private double thresholdPermits;
private final double coldFactor;
SmoothWarmingUp(
SleepingStopwatch stopwatch, long warmupPeriod, TimeUnit timeUnit, double coldFactor) {
super(stopwatch);
this.warmupPeriodMicros = timeUnit.toMicros(warmupPeriod);
this.coldFactor = coldFactor;
}
@Override
void doSetRate(double permitsPerSecond, double stableIntervalMicros) {
double oldMaxPermits = maxPermits;
double coldIntervalMicros = stableIntervalMicros * coldFactor;
thresholdPermits = 0.5 * warmupPeriodMicros / stableIntervalMicros;
maxPermits =
thresholdPermits + 2.0 * warmupPeriodMicros / (stableIntervalMicros + coldIntervalMicros);
slope = (coldIntervalMicros - stableIntervalMicros) / (maxPermits - thresholdPermits);
if (oldMaxPermits == Double.POSITIVE_INFINITY) {
// if we don't special-case this, we would get storedPermits == NaN, below
storedPermits = 0.0;
} else {
storedPermits =
(oldMaxPermits == 0.0)
? maxPermits // initial state is cold
: storedPermits * maxPermits / oldMaxPermits;
}
}
@Override
long storedPermitsToWaitTime(double storedPermits, double permitsToTake) {
double availablePermitsAboveThreshold = storedPermits - thresholdPermits;
long micros = 0;
// measuring the integral on the right part of the function (the climbing line)
if (availablePermitsAboveThreshold > 0.0) {
double permitsAboveThresholdToTake = min(availablePermitsAboveThreshold, permitsToTake);
double length =
permitsToTime(availablePermitsAboveThreshold)
+ permitsToTime(availablePermitsAboveThreshold - permitsAboveThresholdToTake);
micros = (long) (permitsAboveThresholdToTake * length / 2.0);
permitsToTake -= permitsAboveThresholdToTake;
}
// measuring the integral on the left part of the function (the horizontal line)
micros += (long) (stableIntervalMicros * permitsToTake);
return micros;
}
private double permitsToTime(double permits) {
return stableIntervalMicros + permits * slope;
}
@Override
double coolDownIntervalMicros() {
return warmupPeriodMicros / maxPermits;
}
}
/**
* This implements a "bursty" RateLimiter, where storedPermits are translated to zero throttling.
* The maximum number of permits that can be saved (when the RateLimiter is unused) is defined in
* terms of time, in this sense: if a RateLimiter is 2qps, and this time is specified as 10
* seconds, we can save up to 2 * 10 = 20 permits.
*/
static final class SmoothBursty extends SmoothRateLimiter {
/** The work (permits) of how many seconds can be saved up if this RateLimiter is unused? */
final double maxBurstSeconds;
SmoothBursty(SleepingStopwatch stopwatch, double maxBurstSeconds) {
super(stopwatch);
this.maxBurstSeconds = maxBurstSeconds;
}
@Override
void doSetRate(double permitsPerSecond, double stableIntervalMicros) {
double oldMaxPermits = this.maxPermits;
maxPermits = maxBurstSeconds * permitsPerSecond;
if (oldMaxPermits == Double.POSITIVE_INFINITY) {
// if we don't special-case this, we would get storedPermits == NaN, below
storedPermits = maxPermits;
} else {
storedPermits =
(oldMaxPermits == 0.0)
? 0.0 // initial state
: storedPermits * maxPermits / oldMaxPermits;
}
}
@Override
long storedPermitsToWaitTime(double storedPermits, double permitsToTake) {
return 0L;
}
@Override
double coolDownIntervalMicros() {
return stableIntervalMicros;
}
}
/** The currently stored permits. */
double storedPermits;
/** The maximum number of stored permits. */
double maxPermits;
/**
* The interval between two unit requests, at our stable rate. E.g., a stable rate of 5 permits
* per second has a stable interval of 200ms.
*/
double stableIntervalMicros;
/**
* The time when the next request (no matter its size) will be granted. After granting a request,
* this is pushed further in the future. Large requests push this further than small requests.
*/
private long nextFreeTicketMicros = 0L; // could be either in the past or future
private SmoothRateLimiter(SleepingStopwatch stopwatch) {
super(stopwatch);
}
@Override
final void doSetRate(double permitsPerSecond, long nowMicros) {
resync(nowMicros);
double stableIntervalMicros = SECONDS.toMicros(1L) / permitsPerSecond;
this.stableIntervalMicros = stableIntervalMicros;
doSetRate(permitsPerSecond, stableIntervalMicros);
}
abstract void doSetRate(double permitsPerSecond, double stableIntervalMicros);
@Override
final double doGetRate() {
return SECONDS.toMicros(1L) / stableIntervalMicros;
}
@Override
final long queryEarliestAvailable(long nowMicros) {
return nextFreeTicketMicros;
}
@Override
final long reserveEarliestAvailable(int requiredPermits, long nowMicros) {
resync(nowMicros);
long returnValue = nextFreeTicketMicros;
double storedPermitsToSpend = min(requiredPermits, this.storedPermits);
double freshPermits = requiredPermits - storedPermitsToSpend;
long waitMicros =
storedPermitsToWaitTime(this.storedPermits, storedPermitsToSpend)
+ (long) (freshPermits * stableIntervalMicros);
this.nextFreeTicketMicros = LongMath.saturatedAdd(nextFreeTicketMicros, waitMicros);
this.storedPermits -= storedPermitsToSpend;
return returnValue;
}
/**
* Translates a specified portion of our currently stored permits which we want to spend/acquire,
* into a throttling time. Conceptually, this evaluates the integral of the underlying function we
* use, for the range of [(storedPermits - permitsToTake), storedPermits].
*
* <p>This always holds: {@code 0 <= permitsToTake <= storedPermits}
*/
abstract long storedPermitsToWaitTime(double storedPermits, double permitsToTake);
/**
* Returns the number of microseconds during cool down that we have to wait to get a new permit.
*/
abstract double coolDownIntervalMicros();
/** Updates {@code storedPermits} and {@code nextFreeTicketMicros} based on the current time. */
void resync(long nowMicros) {
// if nextFreeTicket is in the past, resync to now
if (nowMicros > nextFreeTicketMicros) {
double newPermits = (nowMicros - nextFreeTicketMicros) / coolDownIntervalMicros();
storedPermits = min(maxPermits, storedPermits + newPermits);
nextFreeTicketMicros = nowMicros;
}
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/ratelimiter/Stopwatch.java
|
/*
* Copyright (C) 2008 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* Copyright 2017 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal.ratelimiter;
import static ai.nextbillion.maps.internal.ratelimiter.Preconditions.checkNotNull;
import static ai.nextbillion.maps.internal.ratelimiter.Preconditions.checkState;
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MICROSECONDS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.util.concurrent.TimeUnit;
/**
* An object that measures elapsed time in nanoseconds. It is useful to measure elapsed time using
* this class instead of direct calls to {@link System#nanoTime} for a few reasons:
*
* <ul>
* <li>An alternate time source can be substituted, for testing or performance reasons.
* <li>As documented by {@code nanoTime}, the value returned has no absolute meaning, and can only
* be interpreted as relative to another timestamp returned by {@code nanoTime} at a different
* time. {@code Stopwatch} is a more effective abstraction because it exposes only these
* relative values, not the absolute ones.
* </ul>
*
* <p>Basic usage:
*
* <pre>{@code
* Stopwatch stopwatch = Stopwatch.createStarted();
* doSomething();
* stopwatch.stop(); // optional
*
* long millis = stopwatch.elapsed(MILLISECONDS);
*
* log.info("time: " + stopwatch); // formatted string like "12.3 ms"
* }</pre>
*
* <p>Stopwatch methods are not idempotent; it is an error to start or stop a stopwatch that is
* already in the desired state.
*
* <p>When testing code that uses this class, use {@link #createUnstarted(Ticker)} or {@link
* #createStarted(Ticker)} to supply a fake or mock ticker. This allows you to simulate any valid
* behavior of the stopwatch.
*
* <p><b>Note:</b> This class is not thread-safe.
*
* <p><b>Warning for Android users:</b> a stopwatch with default behavior may not continue to keep
* time while the device is asleep. Instead, create one like this:
*
* <pre>{@code
* Stopwatch.createStarted(
* new Ticker() {
* public long read() {
* return android.os.SystemClock.elapsedRealtimeNanos();
* }
* });
* }</pre>
*
* @author Kevin Bourrillion
*/
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
public static Stopwatch createUnstarted() {
return new Stopwatch();
}
public static Stopwatch createUnstarted(Ticker ticker) {
return new Stopwatch(ticker);
}
public static Stopwatch createStarted() {
return new Stopwatch().start();
}
public static Stopwatch createStarted(Ticker ticker) {
return new Stopwatch(ticker).start();
}
Stopwatch() {
this.ticker = Ticker.systemTicker();
}
Stopwatch(Ticker ticker) {
this.ticker = checkNotNull(ticker, "ticker");
}
public boolean isRunning() {
return isRunning;
}
public Stopwatch start() {
checkState(!isRunning, "This stopwatch is already running.");
isRunning = true;
startTick = ticker.read();
return this;
}
public Stopwatch stop() {
long tick = ticker.read();
checkState(isRunning, "This stopwatch is already stopped.");
isRunning = false;
elapsedNanos += tick - startTick;
return this;
}
public Stopwatch reset() {
elapsedNanos = 0;
isRunning = false;
return this;
}
private long elapsedNanos() {
return isRunning ? ticker.read() - startTick + elapsedNanos : elapsedNanos;
}
public long elapsed(TimeUnit desiredUnit) {
return desiredUnit.convert(elapsedNanos(), NANOSECONDS);
}
@Override
public String toString() {
long nanos = elapsedNanos();
TimeUnit unit = chooseUnit(nanos);
double value = (double) nanos / NANOSECONDS.convert(1, unit);
// Too bad this functionality is not exposed as a regular method call
return Platform.formatCompact4Digits(value) + " " + abbreviate(unit);
}
private static TimeUnit chooseUnit(long nanos) {
if (DAYS.convert(nanos, NANOSECONDS) > 0) {
return DAYS;
}
if (HOURS.convert(nanos, NANOSECONDS) > 0) {
return HOURS;
}
if (MINUTES.convert(nanos, NANOSECONDS) > 0) {
return MINUTES;
}
if (SECONDS.convert(nanos, NANOSECONDS) > 0) {
return SECONDS;
}
if (MILLISECONDS.convert(nanos, NANOSECONDS) > 0) {
return MILLISECONDS;
}
if (MICROSECONDS.convert(nanos, NANOSECONDS) > 0) {
return MICROSECONDS;
}
return NANOSECONDS;
}
private static String abbreviate(TimeUnit unit) {
switch (unit) {
case NANOSECONDS:
return "ns";
case MICROSECONDS:
return "\u03bcs"; // μs
case MILLISECONDS:
return "ms";
case SECONDS:
return "s";
case MINUTES:
return "min";
case HOURS:
return "h";
case DAYS:
return "d";
default:
throw new AssertionError();
}
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/internal/ratelimiter/Ticker.java
|
/*
* Copyright (C) 2011 The Guava Authors
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/*
* Copyright 2017 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.internal.ratelimiter;
/**
* A time source; returns a time value representing the number of nanoseconds elapsed since some
* fixed but arbitrary point in time. Note that most users should use {@link Stopwatch} instead of
* interacting with this class directly.
*
* <p><b>Warning:</b> this interface can only be used to measure elapsed time, not wall time.
*
* @author Kevin Bourrillion
*/
public abstract class Ticker {
/** Constructor for use by subclasses. */
protected Ticker() {}
public abstract long read();
public static Ticker systemTicker() {
return SYSTEM_TICKER;
}
private static final Ticker SYSTEM_TICKER =
new Ticker() {
@Override
public long read() {
return Platform.systemNanoTime();
}
};
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/metrics/NoOpRequestMetrics.java
|
package ai.nextbillion.maps.metrics;
/** A no-op implementation that does nothing */
final class NoOpRequestMetrics implements RequestMetrics {
NoOpRequestMetrics(String requestName) {}
public void startNetwork() {}
public void endNetwork() {}
public void endRequest(Exception exception, int httpStatusCode, long retryCount) {}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/metrics/NoOpRequestMetricsReporter.java
|
package ai.nextbillion.maps.metrics;
/** A no-op implementation that does nothing */
public final class NoOpRequestMetricsReporter implements RequestMetricsReporter {
public NoOpRequestMetricsReporter() {}
public RequestMetrics newRequest(String requestName) {
return new NoOpRequestMetrics(requestName);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/metrics/OpenCensusMetrics.java
|
package ai.nextbillion.maps.metrics;
import io.opencensus.stats.Aggregation;
import io.opencensus.stats.Aggregation.Count;
import io.opencensus.stats.Aggregation.Distribution;
import io.opencensus.stats.BucketBoundaries;
import io.opencensus.stats.Measure.MeasureLong;
import io.opencensus.stats.Stats;
import io.opencensus.stats.View;
import io.opencensus.stats.ViewManager;
import io.opencensus.tags.TagKey;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/*
* OpenCensus metrics which are measured for every request.
*/
public final class OpenCensusMetrics {
private OpenCensusMetrics() {}
public static final class Tags {
private Tags() {}
public static final TagKey REQUEST_NAME = TagKey.create("request_name");
public static final TagKey HTTP_CODE = TagKey.create("http_code");
public static final TagKey API_STATUS = TagKey.create("api_status");
}
public static final class Measures {
private Measures() {}
public static final MeasureLong LATENCY =
MeasureLong.create(
"maps.googleapis.com/measure/client/latency",
"Total time between library method called and results returned",
"ms");
public static final MeasureLong NETWORK_LATENCY =
MeasureLong.create(
"maps.googleapis.com/measure/client/network_latency",
"Network time inside the library",
"ms");
public static final MeasureLong RETRY_COUNT =
MeasureLong.create(
"maps.googleapis.com/measure/client/retry_count",
"How many times any request was retried",
"1");
}
private static final class Aggregations {
private Aggregations() {}
private static final Aggregation COUNT = Count.create();
private static final Aggregation DISTRIBUTION_INTEGERS_10 =
Distribution.create(
BucketBoundaries.create(
Arrays.asList(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0)));
// every bucket is ~25% bigger = 20 * 2^(N/3)
private static final Aggregation DISTRIBUTION_LATENCY =
Distribution.create(
BucketBoundaries.create(
Arrays.asList(
0.0, 20.0, 25.2, 31.7, 40.0, 50.4, 63.5, 80.0, 100.8, 127.0, 160.0, 201.6,
254.0, 320.0, 403.2, 508.0, 640.0, 806.3, 1015.9, 1280.0, 1612.7, 2031.9,
2560.0, 3225.4, 4063.7)));
}
public static final class Views {
private Views() {}
private static final List<TagKey> fields =
tags(Tags.REQUEST_NAME, Tags.HTTP_CODE, Tags.API_STATUS);
public static final View REQUEST_COUNT =
View.create(
View.Name.create("maps.googleapis.com/client/request_count"),
"Request counts",
Measures.LATENCY,
Aggregations.COUNT,
fields);
public static final View REQUEST_LATENCY =
View.create(
View.Name.create("maps.googleapis.com/client/request_latency"),
"Latency in msecs",
Measures.LATENCY,
Aggregations.DISTRIBUTION_LATENCY,
fields);
public static final View NETWORK_LATENCY =
View.create(
View.Name.create("maps.googleapis.com/client/network_latency"),
"Network latency in msecs (internal)",
Measures.NETWORK_LATENCY,
Aggregations.DISTRIBUTION_LATENCY,
fields);
public static final View RETRY_COUNT =
View.create(
View.Name.create("maps.googleapis.com/client/retry_count"),
"Retries per request",
Measures.RETRY_COUNT,
Aggregations.DISTRIBUTION_INTEGERS_10,
fields);
}
public static void registerAllViews() {
registerAllViews(Stats.getViewManager());
}
public static void registerAllViews(ViewManager viewManager) {
View[] views_to_register =
new View[] {
Views.REQUEST_COUNT, Views.REQUEST_LATENCY, Views.NETWORK_LATENCY, Views.RETRY_COUNT
};
for (View view : views_to_register) {
viewManager.registerView(view);
}
}
private static List<TagKey> tags(TagKey... items) {
return Collections.unmodifiableList(Arrays.asList(items));
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/metrics/OpenCensusRequestMetrics.java
|
package ai.nextbillion.maps.metrics;
import io.opencensus.stats.StatsRecorder;
import io.opencensus.tags.TagContext;
import io.opencensus.tags.TagValue;
import io.opencensus.tags.Tagger;
/** An OpenCensus logger that generates success and latency metrics. */
final class OpenCensusRequestMetrics implements RequestMetrics {
private final String requestName;
private final Tagger tagger;
private final StatsRecorder statsRecorder;
private final long requestStart;
private long networkStart;
private long networkTime;
private boolean finished;
OpenCensusRequestMetrics(String requestName, Tagger tagger, StatsRecorder statsRecorder) {
this.requestName = requestName;
this.tagger = tagger;
this.statsRecorder = statsRecorder;
this.requestStart = milliTime();
this.networkStart = milliTime();
this.networkTime = 0;
this.finished = false;
}
@Override
public void startNetwork() {
this.networkStart = milliTime();
}
@Override
public void endNetwork() {
this.networkTime += milliTime() - this.networkStart;
}
@Override
public void endRequest(Exception exception, int httpStatusCode, long retryCount) {
// multiple endRequest are ignored
if (this.finished) {
return;
}
this.finished = true;
long requestTime = milliTime() - this.requestStart;
TagContext tagContext =
tagger
.currentBuilder()
.putLocal(OpenCensusMetrics.Tags.REQUEST_NAME, TagValue.create(requestName))
.putLocal(
OpenCensusMetrics.Tags.HTTP_CODE, TagValue.create(Integer.toString(httpStatusCode)))
.putLocal(OpenCensusMetrics.Tags.API_STATUS, TagValue.create(exceptionName(exception)))
.build();
statsRecorder
.newMeasureMap()
.put(OpenCensusMetrics.Measures.LATENCY, requestTime)
.put(OpenCensusMetrics.Measures.NETWORK_LATENCY, this.networkTime)
.put(OpenCensusMetrics.Measures.RETRY_COUNT, retryCount)
.record(tagContext);
}
private String exceptionName(Exception exception) {
if (exception == null) {
return "";
} else {
return exception.getClass().getName();
}
}
private long milliTime() {
return System.currentTimeMillis();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/metrics/OpenCensusRequestMetricsReporter.java
|
package ai.nextbillion.maps.metrics;
import io.opencensus.stats.Stats;
import io.opencensus.stats.StatsRecorder;
import io.opencensus.tags.Tagger;
import io.opencensus.tags.Tags;
/** An OpenCensus logger that generates success and latency metrics. */
public final class OpenCensusRequestMetricsReporter implements RequestMetricsReporter {
private static final Tagger tagger = Tags.getTagger();
private static final StatsRecorder statsRecorder = Stats.getStatsRecorder();
public OpenCensusRequestMetricsReporter() {}
@Override
public RequestMetrics newRequest(String requestName) {
return new OpenCensusRequestMetrics(requestName, tagger, statsRecorder);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/metrics/RequestMetrics.java
|
package ai.nextbillion.maps.metrics;
/**
* A type to report common metrics shared among all request types.
*
* <p>If a request retries, there will be multiple calls to all methods below. Ignore any endRequest
* after the first one. For example:
*
* <ol>
* <li>constructor - request starts
* <li>startNetwork / endNetwork - original request
* <li>startNetwork / endNetwork - retried request
* <li>endRequest - request finished (retry)
* <li>endRequest - request finished (original)
* </ol>
*
* <p>The following metrics can be computed: Total queries, successful queries, total latency,
* network latency
*/
public interface RequestMetrics {
void startNetwork();
void endNetwork();
void endRequest(Exception exception, int httpStatusCode, long retryCount);
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/metrics/RequestMetricsReporter.java
|
package ai.nextbillion.maps.metrics;
/** A type to report common metrics shared among all request types. */
public interface RequestMetricsReporter {
RequestMetrics newRequest(String requestName);
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/AddressComponent.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
import java.io.Serializable;
/**
* The parts of an address.
*
* <p>See <a href="https://developers.google.com/maps/documentation/geocoding/intro#Types">Address
* Types and Address Component Types</a> in the <a
* href="https://developers.google.com/maps/documentation/geocoding/intro">Google Maps Geocoding API
* Developer's Guide</a> for more detail.
*/
public class AddressComponent implements Serializable {
private static final long serialVersionUID = 1L;
/** The full text description or name of the address component as returned by the Geocoder. */
public String longName;
/**
* An abbreviated textual name for the address component, if available. For example, an address
* component for the state of Alaska may have a longName of "Alaska" and a shortName of "AK" using
* the 2-letter postal abbreviation.
*/
public String shortName;
/** Indicates the type of each part of the address. Examples include street number or country. */
public AddressComponentType[] types;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[AddressComponent: ");
sb.append("\"").append(longName).append("\"");
if (shortName != null) {
sb.append(" (\"").append(shortName).append("\")");
}
sb.append(" (").append(StringJoin.join(", ", (Object[]) types)).append(")");
sb.append("]");
return sb.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/AddressComponentType.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
/**
* The Address Component types. Please see <a
* href="https://developers.google.com/maps/documentation/geocoding/intro#Types">Address Types and
* Address Component Types</a> for more detail.
*/
public enum AddressComponentType {
/** A precise street address. */
STREET_ADDRESS("street_address"),
/** A named route (such as "US 101"). */
ROUTE("route"),
/** A major intersection, usually of two major roads. */
INTERSECTION("intersection"),
/** A continent. */
CONTINENT("continent"),
/** A political entity. Usually, this type indicates a polygon of some civil administration. */
POLITICAL("political"),
/** A national political entity, typically the highest order type returned by the Geocoder. */
COUNTRY("country"),
/**
* A first-order civil entity below the country level. Within the United States, these
* administrative levels are states. Not all nations exhibit these administrative levels.
*/
ADMINISTRATIVE_AREA_LEVEL_1("administrative_area_level_1"),
/**
* A second-order civil entity below the country level. Within the United States, these
* administrative levels are counties. Not all nations exhibit these administrative levels.
*/
ADMINISTRATIVE_AREA_LEVEL_2("administrative_area_level_2"),
/**
* A third-order civil entity below the country level. This type indicates a minor civil division.
* Not all nations exhibit these administrative levels.
*/
ADMINISTRATIVE_AREA_LEVEL_3("administrative_area_level_3"),
/**
* A fourth-order civil entity below the country level. This type indicates a minor civil
* division. Not all nations exhibit these administrative levels.
*/
ADMINISTRATIVE_AREA_LEVEL_4("administrative_area_level_4"),
/**
* A fifth-order civil entity below the country level. This type indicates a minor civil division.
* Not all nations exhibit these administrative levels.
*/
ADMINISTRATIVE_AREA_LEVEL_5("administrative_area_level_5"),
/** A commonly-used alternative name for the entity. */
COLLOQUIAL_AREA("colloquial_area"),
/** An incorporated city or town political entity. */
LOCALITY("locality"),
/**
* A specific type of Japanese locality, used to facilitate distinction between multiple locality
* components within a Japanese address.
*/
WARD("ward"),
/**
* A first-order civil entity below a locality. For some locations may receive one of the
* additional types: sublocality_level_1 to sublocality_level_5. Each sublocality level is a civil
* entity. Larger numbers indicate a smaller geographic area.
*/
SUBLOCALITY("sublocality"),
SUBLOCALITY_LEVEL_1("sublocality_level_1"),
SUBLOCALITY_LEVEL_2("sublocality_level_2"),
SUBLOCALITY_LEVEL_3("sublocality_level_3"),
SUBLOCALITY_LEVEL_4("sublocality_level_4"),
SUBLOCALITY_LEVEL_5("sublocality_level_5"),
/** A named neighborhood. */
NEIGHBORHOOD("neighborhood"),
/** A named location, usually a building or collection of buildings with a common name. */
PREMISE("premise"),
/**
* A first-order entity below a named location, usually a singular building within a collection of
* buildings with a common name.
*/
SUBPREMISE("subpremise"),
/** A postal code as used to address postal mail within the country. */
POSTAL_CODE("postal_code"),
/** A postal code prefix as used to address postal mail within the country. */
POSTAL_CODE_PREFIX("postal_code_prefix"),
/** A postal code suffix as used to address postal mail within the country. */
POSTAL_CODE_SUFFIX("postal_code_suffix"),
/** A prominent natural feature. */
NATURAL_FEATURE("natural_feature"),
/** An airport. */
AIRPORT("airport"),
/** A named park. */
PARK("park"),
/**
* A named point of interest. Typically, these "POI"s are prominent local entities that don't
* easily fit in another category, such as "Empire State Building" or "Statue of Liberty."
*/
POINT_OF_INTEREST("point_of_interest"),
/** The floor of a building address. */
FLOOR("floor"),
/** Typically indicates a place that has not yet been categorized. */
ESTABLISHMENT("establishment"),
/** A parking lot or parking structure. */
PARKING("parking"),
/** A specific postal box. */
POST_BOX("post_box"),
/**
* A grouping of geographic areas, such as locality and sublocality, used for mailing addresses in
* some countries.
*/
POSTAL_TOWN("postal_town"),
/** The room of a building address. */
ROOM("room"),
/** The precise street number of an address. */
STREET_NUMBER("street_number"),
/** The location of a bus stop. */
BUS_STATION("bus_station"),
/** The location of a train station. */
TRAIN_STATION("train_station"),
/** The location of a subway station. */
SUBWAY_STATION("subway_station"),
/** The location of a transit station. */
TRANSIT_STATION("transit_station"),
/** The location of a light rail station. */
LIGHT_RAIL_STATION("light_rail_station"),
/** A general contractor. */
GENERAL_CONTRACTOR("general_contractor"),
/** A food service establishment. */
FOOD("food"),
/** A real-estate agency. */
REAL_ESTATE_AGENCY("real_estate_agency"),
/** A car-rental establishment. */
CAR_RENTAL("car_rental"),
/** A travel agency. */
TRAVEL_AGENCY("travel_agency"),
/** An electronics store. */
ELECTRONICS_STORE("electronics_store"),
/** A home goods store. */
HOME_GOODS_STORE("home_goods_store"),
/** A school. */
SCHOOL("school"),
/** A store. */
STORE("store"),
/** A shopping mall. */
SHOPPING_MALL("shopping_mall"),
/** A lodging establishment. */
LODGING("lodging"),
/** An art gallery. */
ART_GALLERY("art_gallery"),
/** A lawyer. */
LAWYER("lawyer"),
/** A restaurant. */
RESTAURANT("restaurant"),
/** A bar. */
BAR("bar"),
/** A take-away meal establishment. */
MEAL_TAKEAWAY("meal_takeaway"),
/** A clothing store. */
CLOTHING_STORE("clothing_store"),
/** A local government office. */
LOCAL_GOVERNMENT_OFFICE("local_government_office"),
/** A finance establishment. */
FINANCE("finance"),
/** A moving company. */
MOVING_COMPANY("moving_company"),
/** A storage establishment. */
STORAGE("storage"),
/** A cafe. */
CAFE("cafe"),
/** A car repair establishment. */
CAR_REPAIR("car_repair"),
/** A health service provider. */
HEALTH("health"),
/** An insurance agency. */
INSURANCE_AGENCY("insurance_agency"),
/** A painter. */
PAINTER("painter"),
/** An archipelago. */
ARCHIPELAGO("archipelago"),
/** A museum. */
MUSEUM("museum"),
/** A campground. */
CAMPGROUND("campground"),
/** An RV park. */
RV_PARK("rv_park"),
/** A meal delivery establishment. */
MEAL_DELIVERY("meal_delivery"),
/** A primary school. */
PRIMARY_SCHOOL("primary_school"),
/** A secondary school. */
SECONDARY_SCHOOL("secondary_school"),
/** A town square. */
TOWN_SQUARE("town_square"),
/** Tourist Attraction */
TOURIST_ATTRACTION("tourist_attraction"),
/** Plus code */
PLUS_CODE("plus_code"),
/** DRUGSTORE */
DRUGSTORE("drugstore"),
/**
* Indicates an unknown address component type returned by the server. The Java Client for Google
* Maps Services should be updated to support the new value.
*/
UNKNOWN("unknown");
private final String addressComponentType;
AddressComponentType(final String addressComponentType) {
this.addressComponentType = addressComponentType;
}
@Override
public String toString() {
return addressComponentType;
}
public String toCanonicalLiteral() {
return toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/AddressType.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
/**
* The Address types. Please see <a
* href="https://developers.google.com/maps/documentation/geocoding/intro#Types">Address Types and
* Address Component Types</a> for more detail. Some addresses contain additional place categories.
* Please see <a href="https://developers.google.com/places/supported_types">Place Types</a> for
* more detail.
*/
public enum AddressType implements StringJoin.UrlValue {
/** A precise street address. */
STREET_ADDRESS("street_address"),
/** A precise street number. */
STREET_NUMBER("street_number"),
/** The floor in the address of the building. */
FLOOR("floor"),
/** The room in the address of the building */
ROOM("room"),
/** A specific mailbox. */
POST_BOX("post_box"),
/** A named route (such as "US 101"). */
ROUTE("route"),
/** A major intersection, usually of two major roads. */
INTERSECTION("intersection"),
/** A continent. */
CONTINENT("continent"),
/** A political entity. Usually, this type indicates a polygon of some civil administration. */
POLITICAL("political"),
/** The national political entity, typically the highest order type returned by the Geocoder. */
COUNTRY("country"),
/**
* A first-order civil entity below the country level. Within the United States, these
* administrative levels are states. Not all nations exhibit these administrative levels.
*/
ADMINISTRATIVE_AREA_LEVEL_1("administrative_area_level_1"),
/**
* A second-order civil entity below the country level. Within the United States, these
* administrative levels are counties. Not all nations exhibit these administrative levels.
*/
ADMINISTRATIVE_AREA_LEVEL_2("administrative_area_level_2"),
/**
* A third-order civil entity below the country level. This type indicates a minor civil division.
* Not all nations exhibit these administrative levels.
*/
ADMINISTRATIVE_AREA_LEVEL_3("administrative_area_level_3"),
/**
* A fourth-order civil entity below the country level. This type indicates a minor civil
* division. Not all nations exhibit these administrative levels.
*/
ADMINISTRATIVE_AREA_LEVEL_4("administrative_area_level_4"),
/**
* A fifth-order civil entity below the country level. This type indicates a minor civil division.
* Not all nations exhibit these administrative levels.
*/
ADMINISTRATIVE_AREA_LEVEL_5("administrative_area_level_5"),
/** A commonly-used alternative name for the entity. */
COLLOQUIAL_AREA("colloquial_area"),
/** An incorporated city or town political entity. */
LOCALITY("locality"),
/**
* A specific type of Japanese locality, used to facilitate distinction between multiple locality
* components within a Japanese address.
*/
WARD("ward"),
/**
* A first-order civil entity below a locality. Some locations may receive one of the additional
* types: {@code SUBLOCALITY_LEVEL_1} to {@code SUBLOCALITY_LEVEL_5}. Each sublocality level is a
* civil entity. Larger numbers indicate a smaller geographic area.
*/
SUBLOCALITY("sublocality"),
SUBLOCALITY_LEVEL_1("sublocality_level_1"),
SUBLOCALITY_LEVEL_2("sublocality_level_2"),
SUBLOCALITY_LEVEL_3("sublocality_level_3"),
SUBLOCALITY_LEVEL_4("sublocality_level_4"),
SUBLOCALITY_LEVEL_5("sublocality_level_5"),
/** A named neighborhood. */
NEIGHBORHOOD("neighborhood"),
/** A named location, usually a building or collection of buildings with a common name. */
PREMISE("premise"),
/**
* A first-order entity below a named location, usually a singular building within a collection of
* buildings with a common name.
*/
SUBPREMISE("subpremise"),
/** A postal code as used to address postal mail within the country. */
POSTAL_CODE("postal_code"),
/** A postal code prefix as used to address postal mail within the country. */
POSTAL_CODE_PREFIX("postal_code_prefix"),
/** A postal code prefix as used to address postal mail within the country. */
POSTAL_CODE_SUFFIX("postal_code_suffix"),
/** A prominent natural feature. */
NATURAL_FEATURE("natural_feature"),
/** An airport. */
AIRPORT("airport"),
/** A university. */
UNIVERSITY("university"),
/** A named park. */
PARK("park"),
/** A museum. */
MUSEUM("museum"),
/**
* A named point of interest. Typically, these "POI"s are prominent local entities that don't
* easily fit in another category, such as "Empire State Building" or "Statue of Liberty."
*/
POINT_OF_INTEREST("point_of_interest"),
/** A place that has not yet been categorized. */
ESTABLISHMENT("establishment"),
/** The location of a bus stop. */
BUS_STATION("bus_station"),
/** The location of a train station. */
TRAIN_STATION("train_station"),
/** The location of a subway station. */
SUBWAY_STATION("subway_station"),
/** The location of a transit station. */
TRANSIT_STATION("transit_station"),
/** The location of a light rail station. */
LIGHT_RAIL_STATION("light_rail_station"),
/** The location of a church. */
CHURCH("church"),
/** The location of a primary school. */
PRIMARY_SCHOOL("primary_school"),
/** The location of a secondary school. */
SECONDARY_SCHOOL("secondary_school"),
/** The location of a finance institute. */
FINANCE("finance"),
/** The location of a post office. */
POST_OFFICE("post_office"),
/** The location of a place of worship. */
PLACE_OF_WORSHIP("place_of_worship"),
/**
* A grouping of geographic areas, such as locality and sublocality, used for mailing addresses in
* some countries.
*/
POSTAL_TOWN("postal_town"),
/** Currently not a documented return type. */
SYNAGOGUE("synagogue"),
/** Currently not a documented return type. */
FOOD("food"),
/** Currently not a documented return type. */
GROCERY_OR_SUPERMARKET("grocery_or_supermarket"),
/** Currently not a documented return type. */
STORE("store"),
/** The location of a drugstore. */
DRUGSTORE("drugstore"),
/** Currently not a documented return type. */
LAWYER("lawyer"),
/** Currently not a documented return type. */
HEALTH("health"),
/** Currently not a documented return type. */
INSURANCE_AGENCY("insurance_agency"),
/** Currently not a documented return type. */
GAS_STATION("gas_station"),
/** Currently not a documented return type. */
CAR_DEALER("car_dealer"),
/** Currently not a documented return type. */
CAR_REPAIR("car_repair"),
/** Currently not a documented return type. */
MEAL_TAKEAWAY("meal_takeaway"),
/** Currently not a documented return type. */
FURNITURE_STORE("furniture_store"),
/** Currently not a documented return type. */
HOME_GOODS_STORE("home_goods_store"),
/** Currently not a documented return type. */
SHOPPING_MALL("shopping_mall"),
/** Currently not a documented return type. */
GYM("gym"),
/** Currently not a documented return type. */
ACCOUNTING("accounting"),
/** Currently not a documented return type. */
MOVING_COMPANY("moving_company"),
/** Currently not a documented return type. */
LODGING("lodging"),
/** Currently not a documented return type. */
STORAGE("storage"),
/** Currently not a documented return type. */
CASINO("casino"),
/** Currently not a documented return type. */
PARKING("parking"),
/** Currently not a documented return type. */
STADIUM("stadium"),
/** Currently not a documented return type. */
TRAVEL_AGENCY("travel_agency"),
/** Currently not a documented return type. */
NIGHT_CLUB("night_club"),
/** Currently not a documented return type. */
BEAUTY_SALON("beauty_salon"),
/** Currently not a documented return type. */
HAIR_CARE("hair_care"),
/** Currently not a documented return type. */
SPA("spa"),
/** Currently not a documented return type. */
SHOE_STORE("shoe_store"),
/** Currently not a documented return type. */
BAKERY("bakery"),
/** Currently not a documented return type. */
PHARMACY("pharmacy"),
/** Currently not a documented return type. */
SCHOOL("school"),
/** Currently not a documented return type. */
BOOK_STORE("book_store"),
/** Currently not a documented return type. */
DEPARTMENT_STORE("department_store"),
/** Currently not a documented return type. */
RESTAURANT("restaurant"),
/** Currently not a documented return type. */
REAL_ESTATE_AGENCY("real_estate_agency"),
/** Currently not a documented return type. */
BAR("bar"),
/** Currently not a documented return type. */
DOCTOR("doctor"),
/** Currently not a documented return type. */
HOSPITAL("hospital"),
/** Currently not a documented return type. */
FIRE_STATION("fire_station"),
/** Currently not a documented return type. */
SUPERMARKET("supermarket"),
/** Currently not a documented return type. */
CITY_HALL("city_hall"),
/** Currently not a documented return type. */
LOCAL_GOVERNMENT_OFFICE("local_government_office"),
/** Currently not a documented return type. */
ATM("atm"),
/** Currently not a documented return type. */
BANK("bank"),
/** Currently not a documented return type. */
LIBRARY("library"),
/** Currently not a documented return type. */
CAR_WASH("car_wash"),
/** Currently not a documented return type. */
HARDWARE_STORE("hardware_store"),
/** Currently not a documented return type. */
AMUSEMENT_PARK("amusement_park"),
/** Currently not a documented return type. */
AQUARIUM("aquarium"),
/** Currently not a documented return type. */
ART_GALLERY("art_gallery"),
/** Currently not a documented return type. */
BICYCLE_STORE("bicycle_store"),
/** Currently not a documented return type. */
BOWLING_ALLEY("bowling_alley"),
/** Currently not a documented return type. */
CAFE("cafe"),
/** Currently not a documented return type. */
CAMPGROUND("campground"),
/** Currently not a documented return type. */
CAR_RENTAL("car_rental"),
/** Currently not a documented return type. */
CEMETERY("cemetery"),
/** Currently not a documented return type. */
CLOTHING_STORE("clothing_store"),
/** Currently not a documented return type. */
CONVENIENCE_STORE("convenience_store"),
/** Currently not a documented return type. */
COURTHOUSE("courthouse"),
/** Currently not a documented return type. */
DENTIST("dentist"),
/** Currently not a documented return type. */
ELECTRICIAN("electrician"),
/** Currently not a documented return type. */
ELECTRONICS_STORE("electronics_store"),
/** Currently not a documented return type. */
EMBASSY("embassy"),
/** Currently not a documented return type. */
FLORIST("florist"),
/** Currently not a documented return type. */
FUNERAL_HOME("funeral_home"),
/** Currently not a documented return type. */
GENERAL_CONTRACTOR("general_contractor"),
/** Currently not a documented return type. */
HINDU_TEMPLE("hindu_temple"),
/** Currently not a documented return type. */
JEWELRY_STORE("jewelry_store"),
/** Currently not a documented return type. */
LAUNDRY("laundry"),
/** Currently not a documented return type. */
LIQUOR_STORE("liquor_store"),
/** Currently not a documented return type. */
LOCKSMITH("locksmith"),
/** Currently not a documented return type. */
MEAL_DELIVERY("meal_delivery"),
/** Currently not a documented return type. */
MOSQUE("mosque"),
/** Currently not a documented return type. */
MOVIE_RENTAL("movie_rental"),
/** Currently not a documented return type. */
MOVIE_THEATER("movie_theater"),
/** Currently not a documented return type. */
PAINTER("painter"),
/** Currently not a documented return type. */
PET_STORE("pet_store"),
/** Currently not a documented return type. */
PHYSIOTHERAPIST("physiotherapist"),
/** Currently not a documented return type. */
PLUMBER("plumber"),
/** Currently not a documented return type. */
POLICE("police"),
/** Currently not a documented return type. */
ROOFING_CONTRACTOR("roofing_contractor"),
/** Currently not a documented return type. */
RV_PARK("rv_park"),
/** Currently not a documented return type. */
TAXI_STAND("taxi_stand"),
/** Currently not a documented return type. */
VETERINARY_CARE("veterinary_care"),
/** Currently not a documented return type. */
ZOO("zoo"),
/** An archipelago. */
ARCHIPELAGO("archipelago"),
/** A tourist attraction */
TOURIST_ATTRACTION("tourist_attraction"),
/** Currently not a documented return type. */
TOWN_SQUARE("town_square"),
/**
* Indicates an unknown address type returned by the server. The Java Client for Google Maps
* Services should be updated to support the new value.
*/
UNKNOWN("unknown");
private final String addressType;
AddressType(final String addressType) {
this.addressType = addressType;
}
@Override
public String toString() {
return addressType;
}
public String toCanonicalLiteral() {
return toString();
}
@Override
public String toUrlValue() {
if (this == UNKNOWN) {
throw new UnsupportedOperationException("Shouldn't use AddressType.UNKNOWN in a request.");
}
return addressType;
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/AutocompletePrediction.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.PlaceAutocompleteRequest;
import java.io.Serializable;
import java.util.Arrays;
/**
* Represents a single Autocomplete result returned from the Google Places API Web Service.
*
* <p>Please see <a
* href="https://developers.google.com/places/web-service/query#query_autocomplete_responses">Query
* Autocomplete Responses</a> for more detail.
*/
public class AutocompletePrediction implements Serializable {
private static final long serialVersionUID = 1L;
/** Description of the matched prediction. */
public String description;
/** The Place ID of the place. */
public String placeId;
/**
* An array indicating the type of the address component.
*
* <p>Please see <a href="https://developers.google.com/places/supported_types">supported
* types</a> for a list of types that can be returned.
*/
public String[] types;
/**
* An array of terms identifying each section of the returned description. (A section of the
* description is generally terminated with a comma.) Each entry in the array has a value field,
* containing the text of the term, and an offset field, defining the start position of this term
* in the description, measured in Unicode characters.
*/
public Term[] terms;
/**
* The distance in meters of the place from the {@link PlaceAutocompleteRequest#origin(LatLng)}.
* Optional.
*/
public Integer distanceMeters;
/**
* Describes the location of the entered term in the prediction result text, so that the term can
* be highlighted if desired.
*/
public static class MatchedSubstring implements Serializable {
private static final long serialVersionUID = 1L;
/** The length of the matched substring, measured in Unicode characters. */
public int length;
/** The start position of the matched substring, measured in Unicode characters. */
public int offset;
@Override
public String toString() {
return String.format("(offset=%d, length=%d)", offset, length);
}
}
/**
* The locations of the entered term in the prediction result text, so that the term can be
* highlighted if desired.
*/
public MatchedSubstring[] matchedSubstrings;
/** A description of how the autocomplete query matched the returned result. */
public AutocompleteStructuredFormatting structuredFormatting;
/**
* Identifies each section of the returned description. (A section of the description is generally
* terminated with a comma.)
*/
public static class Term implements Serializable {
private static final long serialVersionUID = 1L;
/** The start position of this term in the description, measured in Unicode characters. */
public int offset;
/** The text of the matched term. */
public String value;
@Override
public String toString() {
return String.format("(offset=%d, value=%s)", offset, value);
}
}
@Override
public String toString() {
return String.format(
"[AutocompletePrediction: \"%s\", placeId=%s, types=%s, terms=%s, "
+ "matchedSubstrings=%s, structuredFormatting=%s]",
description,
placeId,
Arrays.toString(types),
Arrays.toString(terms),
Arrays.toString(matchedSubstrings),
structuredFormatting);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/AutocompleteStructuredFormatting.java
|
/*
* Copyright 2017 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
import java.util.Arrays;
/** The structured formatting info for a {@link AutocompletePrediction}. */
public class AutocompleteStructuredFormatting implements Serializable {
private static final long serialVersionUID = 1L;
/** The main text of a prediction, usually the name of the place. */
public String mainText;
/** Where the query matched the returned main text. */
public AutocompletePrediction.MatchedSubstring[] mainTextMatchedSubstrings;
/** The secondary text of a prediction, usually the location of the place. */
public String secondaryText;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("(");
sb.append("\"").append(mainText).append("\"");
sb.append(" at ").append(Arrays.toString(mainTextMatchedSubstrings));
if (secondaryText != null) {
sb.append(", secondaryText=\"").append(secondaryText).append("\"");
}
sb.append(")");
return sb.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/Bounds.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/** The northeast and southwest points that delineate the outer bounds of a map. */
public class Bounds implements Serializable {
private static final long serialVersionUID = 1L;
/** The northeast corner of the bounding box. */
public LatLng northeast;
/** The southwest corner of the bounding box. */
public LatLng southwest;
@Override
public String toString() {
return String.format("[%s, %s]", northeast, southwest);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/CellTower.java
|
/*
* Copyright 2016 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* A cell tower object.
*
* <p>The Geolocation API request body's cellTowers array contains zero or more cell tower objects.
*
* <p>Please see <a
* href="https://developers.google.com/maps/documentation/geolocation/intro#cell_tower_object">Cell
* Tower Object</a> for more detail.
*/
public class CellTower implements Serializable {
private static final long serialVersionUID = 1L;
public CellTower() {}
// constructor only used by the builder class below
private CellTower(
Integer _cellId,
Integer _locationAreaCode,
Integer _mobileCountryCode,
Integer _mobileNetworkCode,
Integer _age,
Integer _signalStrength,
Integer _timingAdvance) {
this.cellId = _cellId;
this.locationAreaCode = _locationAreaCode;
this.mobileCountryCode = _mobileCountryCode;
this.mobileNetworkCode = _mobileNetworkCode;
this.age = _age;
this.signalStrength = _signalStrength;
this.timingAdvance = _timingAdvance;
}
/**
* Unique identifier of the cell (required). On GSM, this is the Cell ID (CID); CDMA networks use
* the Base Station ID (BID). WCDMA networks use the UTRAN/GERAN Cell Identity (UC-Id), which is a
* 32-bit value concatenating the Radio Network Controller (RNC) and Cell ID. Specifying only the
* 16-bit Cell ID value in WCDMA networks may return inaccurate results.
*/
public Integer cellId = null;
/**
* The Location Area Code (LAC) for GSM and WCDMAnetworks or The Network ID (NID) for CDMA
* networks (required).
*/
public Integer locationAreaCode = null;
/** The cell tower's Mobile Country Code (MCC) (required). */
public Integer mobileCountryCode = null;
/**
* The cell tower's Mobile Network Code (required). This is the MNC for GSM and WCDMA; CDMA uses
* the System ID (SID).
*/
public Integer mobileNetworkCode = null;
/* The following optional fields are not currently used, but may be included if values are available. */
/**
* The number of milliseconds since this cell was primary. If age is 0, the cellId represents a
* current measurement.
*/
public Integer age = null;
/** Radio signal strength measured in dBm. */
public Integer signalStrength = null;
/** The timing advance value. */
public Integer timingAdvance = null;
@Override
public String toString() {
return String.format(
"[CellTower: cellId=%s, locationAreaCode=%s, mobileCountryCode=%s, "
+ "mobileNetworkCode=%s, age=%s, signalStrength=%s, timingAdvance=%s]",
cellId,
locationAreaCode,
mobileCountryCode,
mobileNetworkCode,
age,
signalStrength,
timingAdvance);
}
public static class CellTowerBuilder {
private Integer _cellId = null;
private Integer _locationAreaCode = null;
private Integer _mobileCountryCode = null;
private Integer _mobileNetworkCode = null;
private Integer _age = null;
private Integer _signalStrength = null;
private Integer _timingAdvance = null;
// create the actual cell tower
public CellTower createCellTower() {
return new CellTower(
_cellId,
_locationAreaCode,
_mobileCountryCode,
_mobileNetworkCode,
_age,
_signalStrength,
_timingAdvance);
}
public CellTowerBuilder CellId(int newCellId) {
this._cellId = newCellId;
return this;
}
public CellTowerBuilder LocationAreaCode(int newLocationAreaCode) {
this._locationAreaCode = newLocationAreaCode;
return this;
}
public CellTowerBuilder MobileCountryCode(int newMobileCountryCode) {
this._mobileCountryCode = newMobileCountryCode;
return this;
}
public CellTowerBuilder MobileNetworkCode(int newMobileNetworkCode) {
this._mobileNetworkCode = newMobileNetworkCode;
return this;
}
public CellTowerBuilder Age(int newAge) {
this._age = newAge;
return this;
}
public CellTowerBuilder SignalStrength(int newSignalStrength) {
this._signalStrength = newSignalStrength;
return this;
}
public CellTowerBuilder TimingAdvance(int newTimingAdvance) {
this._timingAdvance = newTimingAdvance;
return this;
}
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/ComponentFilter.java
|
/*
* Copyright 2016 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
/**
* A component filter for a geocode request. In a geocoding response, the Google Geocoding API can
* return address results restricted to a specific area. The restriction is specified using the
* components filter.
*
* <p>Please see <a
* href="https://developers.google.com/maps/documentation/geocoding/intro#ComponentFiltering">Component
* Filtering</a> for more detail.
*/
public class ComponentFilter implements StringJoin.UrlValue {
public final String component;
public final String value;
/**
* Constructs a component filter.
*
* @param component The component to filter.
* @param value The value of the filter.
*/
public ComponentFilter(String component, String value) {
this.component = component;
this.value = value;
}
@Override
public String toString() {
return toUrlValue();
}
@Override
public String toUrlValue() {
return StringJoin.join(':', component, value);
}
/**
* Matches long or short name of a route.
*
* @param route The name of the route to filter on.
* @return Returns a {@link ComponentFilter}.
*/
public static ComponentFilter route(String route) {
return new ComponentFilter("route", route);
}
/**
* Matches against both locality and sublocality types.
*
* @param locality The locality to filter on.
* @return Returns a {@link ComponentFilter}.
*/
public static ComponentFilter locality(String locality) {
return new ComponentFilter("locality", locality);
}
/**
* Matches all the administrative area levels.
*
* @param administrativeArea The administrative area to filter on.
* @return Returns a {@link ComponentFilter}.
*/
public static ComponentFilter administrativeArea(String administrativeArea) {
return new ComponentFilter("administrative_area", administrativeArea);
}
/**
* Matches postal code or postal code prefix.
*
* @param postalCode The postal code to filter on.
* @return Returns a {@link ComponentFilter}.
*/
public static ComponentFilter postalCode(String postalCode) {
return new ComponentFilter("postal_code", postalCode);
}
/**
* Matches a country name or a two letter ISO 3166-1 country code.
*
* @param country The country to filter on.
* @return Returns a {@link ComponentFilter}.
*/
public static ComponentFilter country(String country) {
return new ComponentFilter("country", country);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/DirectionsLeg.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
public class DirectionsLeg implements Serializable {
private static final long serialVersionUID = 1L;
public DirectionsStep[] steps;
/** The total distance covered by this leg. */
public Distance distance;
/** The total duration of this leg. */
public Duration duration;
public Duration raw_duration;
public LatLng startLocation;
public LatLng endLocation;
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/DirectionsResult.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* DirectionsResult represents a result from the Google Directions API Web Service.
*
* <p>Please see <a href="https://developers.google.com/maps/documentation/directions/intro">
* Directions API</a> for more detail.
*/
public class DirectionsResult implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Routes from the origin to the destination. See <a
* href="https://developers.google.com/maps/documentation/directions/intro#Routes">Routes</a> for
* more detail.
*/
public DirectionsRoute[] routes;
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/DirectionsRoute.java
|
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* A Directions API result. When the Directions API returns results, it places them within a routes
* array. Even if the service returns no results (such as if the origin and/or destination doesn't
* exist) it still returns an empty routes array.
*
* <p>Please see <a href="https://developers.google.com/maps/documentation/directions/intro#Routes">
* Routes</a> for more detail.
*/
public class DirectionsRoute implements Serializable {
private static final long serialVersionUID = 1L;
public double distance;
public double duration;
public String geometry;
public double predictedDuration;
public double rawDuration;
public LatLng startLocation;
public LatLng endLocation;
public DirectionsLeg[] legs;
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/DirectionsStep.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
public class DirectionsStep implements Serializable {
private static final long serialVersionUID = 1L;
/** The location of the starting point of this step. */
public LatLng startLocation;
/** The location of the last point of this step. */
public LatLng endLocation;
/** The path of this step. */
public String geometry;
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/Distance.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/** The distance component for Directions API results. */
public class Distance implements Serializable {
private static final long serialVersionUID = 1L;
/**
* The numeric distance, in meters. This is intended to be used only in algorithmic situations,
* e.g. sorting results by some user specified metric.
*/
public long inMeters;
/**
* The human-friendly distance. This is rounded and in an appropriate unit for the request. The
* units can be overridden with a request parameter.
*/
public String humanReadable;
@Override
public String toString() {
return humanReadable;
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/DistanceMatrix.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* A complete result from a Distance Matrix API call.
*
* @see <a
* href="https://developers.google.com/maps/documentation/distancematrix/#DistanceMatrixResponses">
* Distance Matrix Results</a>
*/
public class DistanceMatrix implements Serializable {
private static final long serialVersionUID = 1L;
/**
* An array of elements, each of which in turn contains a status, duration, and distance element.
*/
public final DistanceMatrixRow[] rows;
public DistanceMatrix(DistanceMatrixRow[] rows) {
this.rows = rows;
}
@Override
public String toString() {
return String.format("%d rows", rows.length);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/DistanceMatrixElement.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* A single result corresponding to an origin/destination pair in a Distance Matrix response.
*
* <p>Be sure to check the status for each element, as a matrix response can have a mix of
* successful and failed elements depending on the connectivity of the origin and destination.
*/
public class DistanceMatrixElement implements Serializable {
private static final long serialVersionUID = 1L;
/** The total duration of this leg. */
public Duration duration;
/** {@code distance} indicates the total distance covered by this leg. */
public Distance distance;
public Distance predicted_duration;
public Distance raw_distance;
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/DistanceMatrixElementStatus.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
/**
* The status result for a single {@link DistanceMatrixElement}.
*
* @see <a
* href="https://developers.google.com/maps/documentation/distance-matrix/intro#StatusCodes">
* Documentation on status codes</a>
*/
public enum DistanceMatrixElementStatus {
/** Indicates that the response contains a valid result. */
OK,
/** Indicates that the origin and/or destination of this pairing could not be geocoded. */
NOT_FOUND,
/** Indicates that no route could be found between the origin and destination. */
ZERO_RESULTS
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/DistanceMatrixRow.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* Represents a single row in a Distance Matrix API response. A row represents the results for a
* single origin.
*/
public class DistanceMatrixRow implements Serializable {
private static final long serialVersionUID = 1L;
/** The results for this row, or individual origin. */
public DistanceMatrixElement[] elements;
@Override
public String toString() {
return String.format("[DistanceMatrixRow %d elements]", elements.length);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/Duration.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/** The duration component for Directions API results. */
public class Duration implements Serializable {
private static final long serialVersionUID = 1L;
/**
* The numeric duration, in seconds. This is intended to be used only in algorithmic situations,
* e.g. sorting results by some user specified metric.
*/
public long inSeconds;
/** The human-friendly duration. Use this for display purposes. */
public String humanReadable;
@Override
public String toString() {
return humanReadable;
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/ElevationResult.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* An Elevation API result.
*
* <p>Units are in meters, per https://developers.google.com/maps/documentation/elevation/start.
*/
public class ElevationResult implements Serializable {
private static final long serialVersionUID = 1L;
/** Elevation in meters. */
public double elevation;
/** Location of the elevation data. */
public LatLng location;
/** Maximum distance between data points from which the elevation was interpolated, in meters. */
public double resolution;
@Override
public String toString() {
return String.format("(%s, %f m, resolution=%f m)", location, elevation, resolution);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/EncodedPolyline.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.PolylineEncoding;
import java.io.Serializable;
import java.util.List;
/**
* Encoded Polylines are used by the API to represent paths.
*
* <p>See <a href="https://developers.google.com/maps/documentation/utilities/polylinealgorithm">
* Encoded Polyline Algorithm</a> for more detail on the protocol.
*/
public class EncodedPolyline implements Serializable {
private static final long serialVersionUID = 1L;
private final String points;
public EncodedPolyline() {
this.points = null;
}
/**
* @param encodedPoints A string representation of a path, encoded with the Polyline Algorithm.
*/
public EncodedPolyline(String encodedPoints) {
this.points = encodedPoints;
}
/** @param points A path as a collection of {@code LatLng} points. */
public EncodedPolyline(List<LatLng> points) {
this.points = PolylineEncoding.encode(points);
}
public String getEncodedPath() {
return points;
}
public List<LatLng> decodePath() {
return PolylineEncoding.decode(points);
}
// Use the encoded point representation; decoding to get an alternate representation for
// individual points would be expensive.
@Override
public String toString() {
return String.format("[EncodedPolyline: %s]", points);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/Fare.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Currency;
/**
* A representation of ticket cost for use on public transit.
*
* <p>See the <a href="https://developers.google.com/maps/documentation/directions/intro#Routes">
* Routes Documentation</a> for more detail.
*/
public class Fare implements Serializable {
private static final long serialVersionUID = 1L;
/** The currency that the amount is expressed in. */
public Currency currency;
/** The total fare amount, in the currency specified in {@link #currency}. */
public BigDecimal value;
@Override
public String toString() {
return String.format("%s %s", value, currency);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/FindPlaceFromText.java
|
/*
* Copyright 2018 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
public class FindPlaceFromText implements Serializable {
private static final long serialVersionUID = 1L;
public PlacesSearchResult[] candidates;
@Override
public String toString() {
return String.format("[FindPlaceFromText %d candidates]", candidates.length);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/GeocodedWaypoint.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
import java.util.Arrays;
/**
* A point in a Directions API response; either the origin, one of the requested waypoints, or the
* destination. Please see <a
* href="https://developers.google.com/maps/documentation/directions/intro#GeocodedWaypoints">
* Geocoded Waypoints</a> for more detail.
*/
public class GeocodedWaypoint implements Serializable {
private static final long serialVersionUID = 1L;
/** The status code resulting from the geocoding operation for this waypoint. */
public GeocodedWaypointStatus geocoderStatus;
/**
* Indicates that the geocoder did not return an exact match for the original request, though it
* was able to match part of the requested address.
*/
public boolean partialMatch;
/** A unique identifier for this waypoint that can be used with other Google APIs. */
public String placeId;
/** The address types of the geocoding result used for calculating directions. */
public AddressType[] types;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[GeocodedWaypoint");
sb.append(" ").append(geocoderStatus);
if (partialMatch) {
sb.append(" ").append("PARTIAL MATCH");
}
sb.append(" placeId=").append(placeId);
sb.append(", types=").append(Arrays.toString(types));
return sb.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/GeocodedWaypointStatus.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
/**
* The status result for a single {@link GeocodedWaypoint}.
*
* @see <a href="https://developers.google.com/maps/documentation/directions/intro#StatusCodes">
* Documentation on status codes</a>
*/
public enum GeocodedWaypointStatus {
/** Indicates the response contains a valid result. */
OK,
/** Indicates no route could be found between the origin and destination. */
ZERO_RESULTS
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/GeolocationPayload.java
|
/*
* Copyright 2016 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Request body.
*
* <p>Please see <a
* href="https://developers.google.com/maps/documentation/geolocation/intro#requests">Geolocation
* Requests</a> and <a
* href="https://developers.google.com/maps/documentation/geolocation/intro#body">Request Body</a>
* for more detail.
*
* <p>The following fields are supported, and all fields are optional:
*/
public class GeolocationPayload implements Serializable {
private static final long serialVersionUID = 1L;
public GeolocationPayload() {}
// constructor only used by the builder class below
private GeolocationPayload(
Integer _homeMobileCountryCode,
Integer _homeMobileNetworkCode,
String _radioType,
String _carrier,
Boolean _considerIp,
CellTower[] _cellTowers,
WifiAccessPoint[] _wifiAccessPoints) {
homeMobileCountryCode = _homeMobileCountryCode;
homeMobileNetworkCode = _homeMobileNetworkCode;
radioType = _radioType;
carrier = _carrier;
considerIp = _considerIp;
cellTowers = _cellTowers;
wifiAccessPoints = _wifiAccessPoints;
}
/** The mobile country code (MCC) for the device's home network. */
public Integer homeMobileCountryCode = null;
/** The mobile network code (MNC) for the device's home network. */
public Integer homeMobileNetworkCode = null;
/**
* The mobile radio type. Supported values are {@code "lte"}, {@code "gsm"}, {@code "cdma"}, and
* {@code "wcdma"}. While this field is optional, it should be included if a value is available,
* for more accurate results.
*/
public String radioType = null;
/** The carrier name. */
public String carrier = null;
/**
* Specifies whether to fall back to IP geolocation if wifi and cell tower signals are not
* available. Note that the IP address in the request header may not be the IP of the device.
* Defaults to true. Set considerIp to false to disable fall back.
*/
public Boolean considerIp = null;
/** An array of cell tower objects. See {@link CellTower}. */
public CellTower[] cellTowers;
/** An array of WiFi access point objects. See {@link WifiAccessPoint}. */
public WifiAccessPoint[] wifiAccessPoints;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[GeolocationPayload");
List<String> elements = new ArrayList<>();
if (homeMobileCountryCode != null) {
elements.add("homeMobileCountryCode=" + homeMobileCountryCode);
}
if (homeMobileNetworkCode != null) {
elements.add("homeMobileNetworkCode=" + homeMobileNetworkCode);
}
if (radioType != null) {
elements.add("radioType=" + radioType);
}
if (carrier != null) {
elements.add("carrier=" + carrier);
}
elements.add("considerIp=" + considerIp);
if (cellTowers != null && cellTowers.length > 0) {
elements.add("cellTowers=" + Arrays.toString(cellTowers));
}
if (wifiAccessPoints != null && wifiAccessPoints.length > 0) {
elements.add("wifiAccessPoints=" + Arrays.toString(wifiAccessPoints));
}
sb.append(StringJoin.join(", ", elements));
sb.append("]");
return sb.toString();
}
public static class GeolocationPayloadBuilder {
private Integer _homeMobileCountryCode = null;
private Integer _homeMobileNetworkCode = null;
private String _radioType = null;
private String _carrier = null;
private Boolean _considerIp = null;
private CellTower[] _cellTowers = null;
private final List<CellTower> _addedCellTowers = new ArrayList<>();
private WifiAccessPoint[] _wifiAccessPoints = null;
private final List<WifiAccessPoint> _addedWifiAccessPoints = new ArrayList<>();
public GeolocationPayload createGeolocationPayload() {
// if wifi access points have been added individually...
if (!_addedWifiAccessPoints.isEmpty()) {
// ...use them as our list of access points by converting the list to an array
_wifiAccessPoints = _addedWifiAccessPoints.toArray(new WifiAccessPoint[0]);
} // otherwise we will simply use the array set outright
// same logic as above for cell towers
if (!_addedCellTowers.isEmpty()) {
_cellTowers = _addedCellTowers.toArray(new CellTower[0]);
}
return new GeolocationPayload(
_homeMobileCountryCode,
_homeMobileNetworkCode,
_radioType,
_carrier,
_considerIp,
_cellTowers,
_wifiAccessPoints);
}
public GeolocationPayloadBuilder HomeMobileCountryCode(int newHomeMobileCountryCode) {
this._homeMobileCountryCode = newHomeMobileCountryCode;
return this;
}
public GeolocationPayloadBuilder HomeMobileNetworkCode(int newHomeMobileNetworkCode) {
this._homeMobileNetworkCode = newHomeMobileNetworkCode;
return this;
}
public GeolocationPayloadBuilder RadioType(String newRadioType) {
this._radioType = newRadioType;
return this;
}
public GeolocationPayloadBuilder Carrier(String newCarrier) {
this._carrier = newCarrier;
return this;
}
public GeolocationPayloadBuilder ConsiderIp(boolean newConsiderIp) {
this._considerIp = newConsiderIp;
return this;
}
public GeolocationPayloadBuilder CellTowers(CellTower[] newCellTowers) {
this._cellTowers = newCellTowers;
return this;
}
public GeolocationPayloadBuilder AddCellTower(CellTower newCellTower) {
this._addedCellTowers.add(newCellTower);
return this;
}
public GeolocationPayloadBuilder WifiAccessPoints(WifiAccessPoint[] newWifiAccessPoints) {
this._wifiAccessPoints = newWifiAccessPoints;
return this;
}
public GeolocationPayloadBuilder AddWifiAccessPoint(WifiAccessPoint newWifiAccessPoint) {
this._addedWifiAccessPoints.add(newWifiAccessPoint);
return this;
}
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/GeolocationResult.java
|
/*
* Copyright 2016 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* A Geolocation API result.
*
* <p>A successful geolocation request will return a result defining a location and radius.
*
* <p>Please see <a
* href="https://developers.google.com/maps/documentation/geolocation/intro#responses">Geolocation
* responses</a> for more detail.
*/
public class GeolocationResult implements Serializable {
private static final long serialVersionUID = 1L;
/** The user’s estimated latitude and longitude. */
public LatLng location;
/**
* The accuracy of the estimated location, in meters. This represents the radius of a circle
* around the returned {@code location}.
*/
public double accuracy;
@Override
public String toString() {
return String.format("%s, accuracy=%s m", location, accuracy);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/Geometry.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/** The geometry of a Geocoding result. */
public class Geometry implements Serializable {
private static final long serialVersionUID = 1L;
/**
* The bounding box which can fully contain the returned result (optionally returned). Note that
* these bounds may not match the recommended viewport. (For example, San Francisco includes the
* Farallon islands, which are technically part of the city, but probably should not be returned
* in the viewport.)
*/
public Bounds bounds;
/**
* The geocoded latitude/longitude value. For normal address lookups, this field is typically the
* most important.
*/
public LatLng location;
/** The level of certainty of this geocoding result. */
public LocationType locationType;
/**
* The recommended viewport for displaying the returned result. Generally the viewport is used to
* frame a result when displaying it to a user.
*/
public Bounds viewport;
@Override
public String toString() {
return String.format(
"[Geometry: %s (%s) bounds=%s, viewport=%s]", location, locationType, bounds, viewport);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/LatLng.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
import java.io.Serializable;
import java.util.Locale;
import java.util.Objects;
/** A place on Earth, represented by a latitude/longitude pair. */
public class LatLng implements StringJoin.UrlValue, Serializable {
private static final long serialVersionUID = 1L;
/** The latitude of this location. */
public double lat;
/** The longitude of this location. */
public double lng;
/**
* Constructs a location with a latitude/longitude pair.
*
* @param lat The latitude of this location.
* @param lng The longitude of this location.
*/
public LatLng(double lat, double lng) {
this.lat = lat;
this.lng = lng;
}
/** Serialisation constructor. */
public LatLng() {}
@Override
public String toString() {
return toUrlValue();
}
@Override
public String toUrlValue() {
// Enforce Locale to English for double to string conversion
return String.format(Locale.ENGLISH, "%.8f,%.8f", lat, lng);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
LatLng latLng = (LatLng) o;
return Double.compare(latLng.lat, lat) == 0 && Double.compare(latLng.lng, lng) == 0;
}
@Override
public int hashCode() {
return Objects.hash(lat, lng);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/LocationType.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
/**
* Location types for a reverse geocoding request. Please see <a
* href="https://developers.google.com/maps/documentation/geocoding/start#reverse">Reverse
* Geocoding</a> for more detail.
*/
public enum LocationType implements StringJoin.UrlValue {
/**
* Restricts the results to addresses for which we have location information accurate down to
* street address precision.
*/
ROOFTOP,
/**
* Restricts the results to those that reflect an approximation (usually on a road) interpolated
* between two precise points (such as intersections). An interpolated range generally indicates
* that rooftop geocodes are unavailable for a street address.
*/
RANGE_INTERPOLATED,
/**
* Restricts the results to geometric centers of a location such as a polyline (for example, a
* street) or polygon (region).
*/
GEOMETRIC_CENTER,
/** Restricts the results to those that are characterized as approximate. */
APPROXIMATE,
/**
* Indicates an unknown location type returned by the server. The Java Client for Google Maps
* Services should be updated to support the new value.
*/
UNKNOWN;
@Override
public String toUrlValue() {
if (this == UNKNOWN) {
throw new UnsupportedOperationException("Shouldn't use LocationType.UNKNOWN in a request.");
}
return name();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/OpeningHours.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
import java.time.LocalTime;
import java.util.Arrays;
/**
* Opening hours for a Place Details result. Please see <a
* href="https://developers.google.com/places/web-service/details#PlaceDetailsResults">Place Details
* Results</a> for more details.
*/
public class OpeningHours implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Whether the place is open at the current time.
*
* <p>Note: this field will be null if it isn't present in the response.
*/
public Boolean openNow;
/** The opening hours for a Place for a single day. */
public static class Period implements Serializable {
private static final long serialVersionUID = 1L;
public static class OpenClose implements Serializable {
private static final long serialVersionUID = 1L;
public enum DayOfWeek {
SUNDAY("Sunday"),
MONDAY("Monday"),
TUESDAY("Tuesday"),
WEDNESDAY("Wednesday"),
THURSDAY("Thursday"),
FRIDAY("Friday"),
SATURDAY("Saturday"),
/**
* Indicates an unknown day of week type returned by the server. The Java Client for Google
* Maps Services should be updated to support the new value.
*/
UNKNOWN("Unknown");
DayOfWeek(String name) {
this.name = name;
}
private final String name;
public String getName() {
return name;
}
}
/** Day that this Open/Close pair is for. */
public Period.OpenClose.DayOfWeek day;
/** Time that this Open or Close happens at. */
public LocalTime time;
@Override
public String toString() {
return String.format("%s %s", day, time);
}
}
/** When the Place opens. */
public Period.OpenClose open;
/** When the Place closes. */
public Period.OpenClose close;
@Override
public String toString() {
return String.format("%s - %s", open, close);
}
}
/** Opening periods covering seven days, starting from Sunday, in chronological order. */
public Period[] periods;
/**
* The formatted opening hours for each day of the week, as an array of seven strings; for
* example, {@code "Monday: 8:30 am – 5:30 pm"}.
*/
public String[] weekdayText;
/**
* Indicates that the place has permanently shut down.
*
* <p>Note: this field will be null if it isn't present in the response.
*/
public Boolean permanentlyClosed;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[OpeningHours:");
if (permanentlyClosed != null && permanentlyClosed) {
sb.append(" permanentlyClosed");
}
if (openNow != null && openNow) {
sb.append(" openNow");
}
sb.append(" ").append(Arrays.toString(periods));
return sb.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/Photo.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* Describes a photo available with a Search Result.
*
* <p>Please see <a href="https://developers.google.com/places/web-service/photos">Place Photos</a>
* for more details.
*/
public class Photo implements Serializable {
private static final long serialVersionUID = 1L;
/** Used to identify the photo when you perform a Photo request. */
public String photoReference;
/** The maximum height of the image. */
public int height;
/** The maximum width of the image. */
public int width;
/** Attributions about this listing which must be displayed to the user. */
public String[] htmlAttributions;
@Override
public String toString() {
String str = String.format("[Photo %s (%d x %d)", photoReference, width, height);
if (htmlAttributions != null && htmlAttributions.length > 0) {
str = str + " " + htmlAttributions.length + " attributions";
}
str = str + "]";
return str;
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/PlaceAutocompleteType.java
|
/*
* Copyright 2016 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
/**
* Used by the Places API to restrict the autocomplete results to places matching the specified
* type.
*/
public enum PlaceAutocompleteType implements StringJoin.UrlValue {
GEOCODE("geocode"),
ADDRESS("address"),
ESTABLISHMENT("establishment"),
REGIONS("(regions)"),
CITIES("(cities)");
PlaceAutocompleteType(final String placeType) {
this.placeType = placeType;
}
private final String placeType;
@Override
public String toUrlValue() {
return placeType;
}
@Override
public String toString() {
return placeType;
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/PlaceDetails.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
import java.net.URL;
import java.time.Instant;
import java.util.Arrays;
/**
* The result of a Place Details request. A Place Details request returns more comprehensive
* information about the indicated place such as its complete address, phone number, user rating,
* and reviews.
*
* <p>See <a href="https://developers.google.com/places/web-service/details#PlaceDetailsResults">
* Place Details Results</a> for more detail.
*/
public class PlaceDetails implements Serializable {
private static final long serialVersionUID = 1L;
/** A list of separate address components that comprise the address of this place. */
public AddressComponent[] addressComponents;
/** A representation of the place's address in the adr microformat. */
public String adrAddress;
/** The human-readable address of this place. */
public String formattedAddress;
/** The place's phone number in its local format. */
public String formattedPhoneNumber;
/** The location of the Place. */
public Geometry geometry;
/**
* The URL of a suggested icon which may be displayed to the user when indicating this result on a
* map.
*/
public URL icon;
/**
* The place's phone number in international format. International format includes the country
* code, and is prefixed with the plus (+) sign.
*/
public String internationalPhoneNumber;
/** The human-readable name for the returned result. */
public String name;
/** The opening hours for the place. */
public OpeningHours openingHours;
/** A list of photos associated with this place, each containing a reference to an image. */
public Photo[] photos;
/** A textual identifier that uniquely identifies this place. */
public String placeId;
/** The scope of the placeId. */
@Deprecated public PlaceIdScope scope;
/** The Plus Code location identifier for this place. */
public PlusCode plusCode;
/** Whether the place has permanently closed. */
public boolean permanentlyClosed;
/** The number of user reviews for this place */
public int userRatingsTotal;
@Deprecated
public static class AlternatePlaceIds implements Serializable {
private static final long serialVersionUID = 1L;
/**
* The alternative placeId. The most likely reason for a place to have an alternative place ID
* is if your application adds a place and receives an application-scoped place ID, then later
* receives a Google-scoped place ID after passing the moderation process.
*/
public String placeId;
/**
* The scope of an alternative place ID will always be APP, indicating that the alternative
* place ID is recognised by your application only.
*/
public PlaceIdScope scope;
@Override
public String toString() {
return String.format("%s (%s)", placeId, scope);
}
}
/**
* An optional array of alternative place IDs for the place, with a scope related to each
* alternative ID.
*/
public AlternatePlaceIds[] altIds;
/**
* The price level of the place. The exact amount indicated by a specific value will vary from
* region to region.
*/
public PriceLevel priceLevel;
/** The place's rating, from 1.0 to 5.0, based on aggregated user reviews. */
public float rating;
public static class Review implements Serializable {
private static final long serialVersionUID = 1L;
public static class AspectRating implements Serializable {
private static final long serialVersionUID = 1L;
public enum RatingType {
APPEAL,
ATMOSPHERE,
DECOR,
FACILITIES,
FOOD,
OVERALL,
QUALITY,
SERVICE,
/**
* Indicates an unknown rating type returned by the server. The Java Client for Google Maps
* Services should be updated to support the new value.
*/
UNKNOWN
}
/** The name of the aspect that is being rated. */
public RatingType type;
/** The user's rating for this particular aspect, from 0 to 3. */
public int rating;
}
/**
* A list of AspectRating objects, each of which provides a rating of a single attribute of the
* establishment.
*
* <p>Note: this is a <a
* href="https://developers.google.com/places/web-service/details#PremiumData">Premium Data</a>
* field available to the Google Places API for Work customers.
*/
public AspectRating[] aspects;
/**
* The name of the user who submitted the review. Anonymous reviews are attributed to "A Google
* user".
*/
public String authorName;
/** The URL of the user's Google+ profile, if available. */
public URL authorUrl;
/** An IETF language code indicating the language used in the user's review. */
public String language;
/** The URL of the user's Google+ profile photo, if available. */
public String profilePhotoUrl;
/** The user's overall rating for this place. This is a whole number, ranging from 1 to 5. */
public int rating;
/** The relative time that the review was submitted. */
public String relativeTimeDescription;
/**
* The user's review. When reviewing a location with Google Places, text reviews are considered
* optional.
*/
public String text;
/** The time that the review was submitted. */
public Instant time;
}
/**
* An array of up to five reviews. If a language parameter was specified in the Place Details
* request, the Places Service will bias the results to prefer reviews written in that language.
*/
public Review[] reviews;
/** Feature types describing the given result. */
public AddressType[] types;
/**
* The URL of the official Google page for this place. This will be the establishment's Google+
* page if the Google+ page exists, otherwise it will be the Google-owned page that contains the
* best available information about the place. Applications must link to or embed this page on any
* screen that shows detailed results about the place to the user.
*/
public URL url;
/** The number of minutes this place’s current timezone is offset from UTC. */
public int utcOffset;
/**
* A simplified address for the place, including the street name, street number, and locality, but
* not the province/state, postal code, or country.
*/
public String vicinity;
/** The authoritative website for this place, such as a business's homepage. */
public URL website;
/** Attributions about this listing which must be displayed to the user. */
public String[] htmlAttributions;
/** The status of the business (i.e. operational, temporarily closed, etc.). */
public String businessStatus;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[PlaceDetails: ");
sb.append("\"").append(name).append("\"");
sb.append(" ").append(placeId).append(" (").append(scope).append(")");
sb.append(" address=\"").append(formattedAddress).append("\"");
sb.append(" geometry=").append(geometry);
if (vicinity != null) {
sb.append(", vicinity=").append(vicinity);
}
if (types != null && types.length > 0) {
sb.append(", types=").append(Arrays.toString(types));
}
if (altIds != null && altIds.length > 0) {
sb.append(", altIds=").append(Arrays.toString(altIds));
}
if (formattedPhoneNumber != null) {
sb.append(", phone=").append(formattedPhoneNumber);
}
if (internationalPhoneNumber != null) {
sb.append(", internationalPhoneNumber=").append(internationalPhoneNumber);
}
if (url != null) {
sb.append(", url=").append(url);
}
if (website != null) {
sb.append(", website=").append(website);
}
if (icon != null) {
sb.append(", icon");
}
if (openingHours != null) {
sb.append(", openingHours");
sb.append(", utcOffset=").append(utcOffset);
}
if (priceLevel != null) {
sb.append(", priceLevel=").append(priceLevel);
}
sb.append(", rating=").append(rating);
if (permanentlyClosed) {
sb.append(", permanentlyClosed");
}
if (userRatingsTotal > 0) {
sb.append(", userRatingsTotal=").append(userRatingsTotal);
}
if (photos != null && photos.length > 0) {
sb.append(", ").append(photos.length).append(" photos");
}
if (reviews != null && reviews.length > 0) {
sb.append(", ").append(reviews.length).append(" reviews");
}
if (htmlAttributions != null && htmlAttributions.length > 0) {
sb.append(", ").append(htmlAttributions.length).append(" htmlAttributions");
}
if (businessStatus != null) {
sb.append(", businessStatus=").append(businessStatus);
}
sb.append("]");
return sb.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/PlaceIdScope.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
/** The scope of a Place ID returned from the Google Places API Web Service. */
@Deprecated
public enum PlaceIdScope {
/**
* Indicates the place ID is recognised by your application only. This is because your application
* added the place, and the place has not yet passed the moderation process.
*/
APP,
/** Indicates the place ID is available to other applications and on Google Maps. */
GOOGLE
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/PlaceType.java
|
/*
* Copyright 2016 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
/** Used by the Places API to restrict the results to places matching the specified type. */
public enum PlaceType implements StringJoin.UrlValue {
ACCOUNTING("accounting"),
AIRPORT("airport"),
AMUSEMENT_PARK("amusement_park"),
AQUARIUM("aquarium"),
ART_GALLERY("art_gallery"),
ATM("atm"),
BAKERY("bakery"),
BANK("bank"),
BAR("bar"),
BEAUTY_SALON("beauty_salon"),
BICYCLE_STORE("bicycle_store"),
BOOK_STORE("book_store"),
BOWLING_ALLEY("bowling_alley"),
BUS_STATION("bus_station"),
CAFE("cafe"),
CAMPGROUND("campground"),
CAR_DEALER("car_dealer"),
CAR_RENTAL("car_rental"),
CAR_REPAIR("car_repair"),
CAR_WASH("car_wash"),
CASINO("casino"),
CEMETERY("cemetery"),
CHURCH("church"),
CITY_HALL("city_hall"),
CLOTHING_STORE("clothing_store"),
CONVENIENCE_STORE("convenience_store"),
COURTHOUSE("courthouse"),
DENTIST("dentist"),
DEPARTMENT_STORE("department_store"),
DOCTOR("doctor"),
DRUGSTORE("drugstore"),
ELECTRICIAN("electrician"),
ELECTRONICS_STORE("electronics_store"),
EMBASSY("embassy"),
@Deprecated
ESTABLISHMENT("establishment"),
@Deprecated
FINANCE("finance"),
FIRE_STATION("fire_station"),
FLORIST("florist"),
@Deprecated
FOOD("food"),
FUNERAL_HOME("funeral_home"),
FURNITURE_STORE("furniture_store"),
GAS_STATION("gas_station"),
@Deprecated
GENERAL_CONTRACTOR("general_contractor"),
GROCERY_OR_SUPERMARKET("grocery_or_supermarket"),
GYM("gym"),
HAIR_CARE("hair_care"),
HARDWARE_STORE("hardware_store"),
@Deprecated
HEALTH("health"),
HINDU_TEMPLE("hindu_temple"),
HOME_GOODS_STORE("home_goods_store"),
HOSPITAL("hospital"),
INSURANCE_AGENCY("insurance_agency"),
JEWELRY_STORE("jewelry_store"),
LAUNDRY("laundry"),
LAWYER("lawyer"),
LIBRARY("library"),
LIGHT_RAIL_STATION("light_rail_station"),
LIQUOR_STORE("liquor_store"),
LOCAL_GOVERNMENT_OFFICE("local_government_office"),
LOCKSMITH("locksmith"),
LODGING("lodging"),
MEAL_DELIVERY("meal_delivery"),
MEAL_TAKEAWAY("meal_takeaway"),
MOSQUE("mosque"),
MOVIE_RENTAL("movie_rental"),
MOVIE_THEATER("movie_theater"),
MOVING_COMPANY("moving_company"),
MUSEUM("museum"),
NIGHT_CLUB("night_club"),
PAINTER("painter"),
PARK("park"),
PARKING("parking"),
PET_STORE("pet_store"),
PHARMACY("pharmacy"),
PHYSIOTHERAPIST("physiotherapist"),
@Deprecated
PLACE_OF_WORSHIP("place_of_worship"),
PLUMBER("plumber"),
POLICE("police"),
POST_OFFICE("post_office"),
PRIMARY_SCHOOL("primary_school"),
REAL_ESTATE_AGENCY("real_estate_agency"),
RESTAURANT("restaurant"),
ROOFING_CONTRACTOR("roofing_contractor"),
RV_PARK("rv_park"),
SCHOOL("school"),
SECONDARY_SCHOOL("secondary_school"),
SHOE_STORE("shoe_store"),
SHOPPING_MALL("shopping_mall"),
SPA("spa"),
STADIUM("stadium"),
STORAGE("storage"),
STORE("store"),
SUBWAY_STATION("subway_station"),
SUPERMARKET("supermarket"),
SYNAGOGUE("synagogue"),
TAXI_STAND("taxi_stand"),
TOURIST_ATTRACTION("tourist_attraction"),
TRAIN_STATION("train_station"),
TRANSIT_STATION("transit_station"),
TRAVEL_AGENCY("travel_agency"),
UNIVERSITY("university"),
VETERINARY_CARE("veterinary_care"),
ZOO("zoo");
PlaceType(final String placeType) {
this.placeType = placeType;
}
private final String placeType;
@Override
public String toUrlValue() {
return placeType;
}
@Override
public String toString() {
return placeType;
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/PlacesSearchResponse.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* The response from a Places Search request.
*
* <p>Please see <a
* href="https://developers.google.com/places/web-service/search#PlaceSearchResponses">Places Search
* Response</a> for more detail.
*/
public class PlacesSearchResponse implements Serializable {
private static final long serialVersionUID = 1L;
/** The list of Search Results. */
public PlacesSearchResult[] results;
/** Attributions about this listing which must be displayed to the user. */
public String[] htmlAttributions;
/**
* A token that can be used to request up to 20 additional results. This field will be null if
* there are no further results. The maximum number of results that can be returned is 60.
*
* <p>Note: There is a short delay between when this response is issued, and when nextPageToken
* will become valid to execute.
*/
public String nextPageToken;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[PlacesSearchResponse: ");
sb.append(results.length).append(" results");
if (nextPageToken != null) {
sb.append(", nextPageToken=").append(nextPageToken);
}
if (htmlAttributions != null && htmlAttributions.length > 0) {
sb.append(", ").append(htmlAttributions.length).append(" htmlAttributions");
}
sb.append("]");
return sb.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/PlacesSearchResult.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
import java.net.URL;
import java.util.Arrays;
/**
* A single result in the search results returned from the Google Places API Web Service.
*
* <p>Please see <a
* href="https://developers.google.com/places/web-service/search#PlaceSearchResults">Place Search
* Results</a> for more detail.
*/
public class PlacesSearchResult implements Serializable {
private static final long serialVersionUID = 1L;
/** The human-readable address of this place. */
public String formattedAddress;
/**
* Geometry information about the result, generally including the location (geocode) of the place
* and (optionally) the viewport identifying its general area of coverage.
*/
public Geometry geometry;
/**
* The human-readable name for the returned result. For establishment results, this is usually the
* business name.
*/
public String name;
/**
* The URL of a recommended icon which may be displayed to the user when indicating this result.
*/
public URL icon;
/** A textual identifier that uniquely identifies a place. */
public String placeId;
/** The scope of the placeId. */
@Deprecated public PlaceIdScope scope;
/** The place's rating, from 1.0 to 5.0, based on aggregated user reviews. */
public float rating;
/** Feature types describing the given result. */
public String[] types;
/** Information on when the place is open. */
public OpeningHours openingHours;
/** Photo objects associated with this place, each containing a reference to an image. */
public Photo[] photos;
/** A feature name of a nearby location. */
public String vicinity;
/** Indicates that the place has permanently shut down. */
public boolean permanentlyClosed;
/** The number of user reviews for this place */
public int userRatingsTotal;
/** The status of the business (i.e. operational, temporarily closed, etc.). */
public String businessStatus;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[PlacesSearchResult: ");
sb.append("\"").append(name).append("\"");
sb.append(", \"").append(formattedAddress).append("\"");
sb.append(", geometry=").append(geometry);
sb.append(", placeId=").append(placeId);
if (vicinity != null) {
sb.append(", vicinity=").append(vicinity);
}
if (types != null && types.length > 0) {
sb.append(", types=").append(Arrays.toString(types));
}
sb.append(", rating=").append(rating);
if (icon != null) {
sb.append(", icon");
}
if (openingHours != null) {
sb.append(", openingHours");
}
if (photos != null && photos.length > 0) {
sb.append(", ").append(photos.length).append(" photos");
}
if (permanentlyClosed) {
sb.append(", permanentlyClosed");
}
if (userRatingsTotal > 0) {
sb.append(", userRatingsTotal=").append(userRatingsTotal);
}
if (businessStatus != null) {
sb.append(", businessStatus=").append(businessStatus);
}
sb.append("]");
return sb.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/PlusCode.java
|
/*
* Copyright 2018 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/** A Plus Code encoded location reference. */
public class PlusCode implements Serializable {
private static final long serialVersionUID = 1L;
/** The global Plus Code identifier. */
public String globalCode;
/** The compound Plus Code identifier. May be null for locations in remote areas. */
public String compoundCode;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[PlusCode: ");
sb.append(globalCode);
if (compoundCode != null) {
sb.append(", compoundCode=").append(compoundCode);
}
sb.append("]");
return sb.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/PriceLevel.java
|
/*
* Copyright 2016 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
/** Used by Places API to restrict search results to those within a given price range. */
public enum PriceLevel implements StringJoin.UrlValue {
FREE("0"),
INEXPENSIVE("1"),
MODERATE("2"),
EXPENSIVE("3"),
VERY_EXPENSIVE("4"),
/**
* Indicates an unknown price level type returned by the server. The Java Client for Google Maps
* Services should be updated to support the new value.
*/
UNKNOWN("Unknown");
private final String priceLevel;
PriceLevel(final String priceLevel) {
this.priceLevel = priceLevel;
}
@Override
public String toString() {
return priceLevel;
}
@Override
public String toUrlValue() {
if (this == UNKNOWN) {
throw new UnsupportedOperationException("Shouldn't use PriceLevel.UNKNOWN in a request.");
}
return priceLevel;
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/RankBy.java
|
/*
* Copyright 2016 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
/** Used by the Places API to specify the order in which results are listed. */
public enum RankBy implements StringJoin.UrlValue {
PROMINENCE("prominence"),
DISTANCE("distance");
private final String ranking;
RankBy(String ranking) {
this.ranking = ranking;
}
@Override
public String toString() {
return ranking;
}
@Override
public String toUrlValue() {
return ranking;
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/Size.java
|
/*
* Copyright 2018 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
import java.io.Serializable;
public class Size implements StringJoin.UrlValue, Serializable {
private static final long serialVersionUID = 1L;
/** The width of this Size. */
public int width;
/** The height of this Size. */
public int height;
/**
* Constructs a Size with a height/width pair.
*
* @param height The height of this Size.
* @param width The width of this Size.
*/
public Size(int width, int height) {
this.width = width;
this.height = height;
}
/** Serialization constructor. */
public Size() {}
@Override
public String toString() {
return toUrlValue();
}
@Override
public String toUrlValue() {
return String.format("%dx%d", width, height);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/SnappedPoint.java
|
package ai.nextbillion.maps.model;
import java.io.Serializable;
/** A point that has been snapped to a road by the Roads API. */
public class SnappedPoint implements Serializable {
private static final long serialVersionUID = 1L;
/** A latitude/longitude value representing the snapped location. */
public LatLng location;
/**
* The index of the corresponding value in the original request. Each value in the request should
* map to a snapped value in the response. However, if you've set interpolate=true, then it's
* possible that the response will contain more coordinates than the request. Interpolated values
* will not have an originalIndex. These values are indexed from 0, so a point with an
* originalIndex of 4 will be the snapped value of the 5th lat/lng passed to the path parameter.
*
* <p>A point that was not on the original path, or when interpolate=false, will have an
* originalIndex of -1.
*/
public int originalIndex = -1;
@Override
public String toString() {
return String.format("[%s, originalIndex=%s]", location, originalIndex);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/SnappedSpeedLimitResponse.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/** A combined snap-to-roads and speed limit response. */
public class SnappedSpeedLimitResponse implements Serializable {
private static final long serialVersionUID = 1L;
/** Speed limit results. */
public SpeedLimit[] speedLimits;
/** Snap-to-road results. */
public SnappedPoint[] snappedPoints;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[SnappedSpeedLimitResponse:");
if (speedLimits != null && speedLimits.length > 0) {
sb.append(" ").append(speedLimits.length).append(" speedLimits");
}
if (snappedPoints != null && snappedPoints.length > 0) {
sb.append(" ").append(snappedPoints.length).append(" speedLimits");
}
sb.append("]");
return sb.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/SpeedLimit.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/** A speed limit result from the Roads API. */
public class SpeedLimit implements Serializable {
private static final long serialVersionUID = 1L;
/**
* A unique identifier for a place. All placeIds returned by the Roads API will correspond to road
* segments.
*/
public String placeId;
/**
* The speed limit for that road segment, specified in kilometers per hour.
*
* <p>To obtain the speed in miles per hour, use {@link #speedLimitMph()}.
*/
public double speedLimit;
/** @return Returns the speed limit in miles per hour (MPH). */
public long speedLimitMph() {
return Math.round(speedLimit * 0.621371);
}
@Override
public String toString() {
return String.format("[%.0f km/h, placeId=%s]", speedLimit, placeId);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/StopDetails.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* The stop/station.
*
* <p>See <a
* href="https://developers.google.com/maps/documentation/directions/intro#TransitDetails">Transit
* details</a> for more detail.
*/
public class StopDetails implements Serializable {
private static final long serialVersionUID = 1L;
/** The name of the transit station/stop. E.g. {@code "Union Square"}. */
public String name;
/** The location of the transit station/stop. */
public LatLng location;
@Override
public String toString() {
return String.format("%s (%s)", name, location);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/TrafficModel.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
import java.util.Locale;
/** Specifies traffic prediction model when requesting future directions. */
public enum TrafficModel implements StringJoin.UrlValue {
BEST_GUESS,
OPTIMISTIC,
PESSIMISTIC;
@Override
public String toString() {
return name().toLowerCase(Locale.ENGLISH);
}
@Override
public String toUrlValue() {
return toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/TransitAgency.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* The operator of a line.
*
* <p>See <a
* href="https://developers.google.com/maps/documentation/directions/intro#TransitDetails">Transit
* Details</a> for more detail.
*/
public class TransitAgency implements Serializable {
private static final long serialVersionUID = 1L;
/** The name of the transit agency. */
public String name;
/** The URL for the transit agency. */
public String url;
/** The phone number of the transit agency. */
public String phone;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[TransitAgency: ");
sb.append(name);
if (url != null) {
sb.append(", url=").append(url);
}
if (phone != null) {
sb.append(", phone=").append(phone);
}
sb.append("]");
return sb.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/TransitDetails.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
import java.time.ZonedDateTime;
/**
* Transit directions return additional information that is not relevant for other modes of
* transportation. These additional properties are exposed through the {@code TransitDetails}
* object, returned as a field of an element in the {@code steps} array. From the {@code
* TransitDetails} object you can access additional information about the transit stop, transit
* line, and transit agency.
*/
public class TransitDetails implements Serializable {
private static final long serialVersionUID = 1L;
/** Information about the arrival stop/station for this part of the trip. */
public StopDetails arrivalStop;
/** Information about the departure stop/station for this part of the trip. */
public StopDetails departureStop;
/** The arrival time for this leg of the journey. */
public ZonedDateTime arrivalTime;
/** The departure time for this leg of the journey. */
public ZonedDateTime departureTime;
/**
* The direction in which to travel on this line, as it is marked on the vehicle or at the
* departure stop. This will often be the terminus station.
*/
public String headsign;
/**
* The expected number of seconds between departures from the same stop at this time. For example,
* with a headway value of 600, you would expect a ten minute wait if you should miss your bus.
*/
public long headway;
/**
* The number of stops in this step, counting the arrival stop, but not the departure stop. For
* example, if your directions involve leaving from Stop A, passing through stops B and C, and
* arriving at stop D, {@code numStops} will equal 3.
*/
public int numStops;
/** Information about the transit line used in this step. */
public TransitLine line;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[");
sb.append(departureStop).append(" at ").append(departureTime);
sb.append(" -> ");
sb.append(arrivalStop).append(" at ").append(arrivalTime);
if (headsign != null) {
sb.append(" (").append(headsign).append(" )");
}
if (line != null) {
sb.append(" on ").append(line);
}
sb.append(", ").append(numStops).append(" stops");
sb.append(", headway=").append(headway).append(" s");
sb.append("]");
return sb.toString();
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/TransitLine.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* The transit line used in a step.
*
* <p>See <a
* href="https://developers.google.com/maps/documentation/directions/intro#TransitDetails">Transit
* Details</a> for more detail.
*/
public class TransitLine implements Serializable {
private static final long serialVersionUID = 1L;
/** The full name of this transit line. E.g. {@code "7 Avenue Express"}. */
public String name;
/**
* The short name of this transit line. This will normally be a line number, such as {@code "M7"}
* or {@code "355"}.
*/
public String shortName;
/**
* The color commonly used in signage for this transit line. The color will be specified as a hex
* string, such as {@code "#FF0033"}.
*/
public String color;
/** Information about the operator(s) of this transit line. */
public TransitAgency[] agencies;
/** The URL for this transit line as provided by the transit agency. */
public String url;
/** The URL for the icon associated with this transit line. */
public String icon;
/**
* The color of text commonly used for signage of this transit line. The color will be specified
* as a hex string, such as {@code "#FF0033"}.
*/
public String textColor;
/** The type of vehicle used on this transit line. */
public Vehicle vehicle;
@Override
public String toString() {
return String.format("%s \"%s\"", shortName, name);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/TransitMode.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
import java.util.Locale;
/** You may specify transit mode when requesting transit directions or distances. */
public enum TransitMode implements StringJoin.UrlValue {
BUS,
SUBWAY,
TRAIN,
TRAM,
/** Indicates preferred travel by train, tram, light rail and subway. */
RAIL;
@Override
public String toString() {
return name().toLowerCase(Locale.ENGLISH);
}
@Override
public String toUrlValue() {
return name().toLowerCase(Locale.ENGLISH);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/TransitRoutingPreference.java
|
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
import java.util.Locale;
/** Indicates user preference when requesting transit directions. */
public enum TransitRoutingPreference implements StringJoin.UrlValue {
LESS_WALKING,
FEWER_TRANSFERS;
@Override
public String toString() {
return name().toLowerCase(Locale.ENGLISH);
}
@Override
public String toUrlValue() {
return name().toLowerCase(Locale.ENGLISH);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/TravelMode.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
import java.util.Locale;
/**
* You may specify the transportation mode to use for calulating directions. Directions are
* calculating as driving directions by default.
*
* @see <a href="https://developers.google.com/maps/documentation/directions/intro#TravelModes">
* Directions API travel modes</a>
* @see <a href="https://developers.google.com/maps/documentation/distance-matrix/intro">Distance
* Matrix API Intro</a>
*/
public enum TravelMode implements StringJoin.UrlValue {
DRIVING,
WALKING,
BICYCLING,
TRANSIT,
/**
* Indicates an unknown travel mode returned by the server. The Java Client for Google Maps
* Services should be updated to support the new value.
*/
UNKNOWN;
@Override
public String toString() {
return name().toLowerCase(Locale.ENGLISH);
}
@Override
public String toUrlValue() {
if (this == UNKNOWN) {
throw new UnsupportedOperationException("Shouldn't use TravelMode.UNKNOWN in a request.");
}
return name().toLowerCase(Locale.ENGLISH);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/Unit.java
|
/*
* Copyright 2014 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import ai.nextbillion.maps.internal.StringJoin;
import java.util.Locale;
/** Units of measurement. */
public enum Unit implements StringJoin.UrlValue {
METRIC,
IMPERIAL;
@Override
public String toString() {
return toUrlValue();
}
@Override
public String toUrlValue() {
return name().toLowerCase(Locale.ENGLISH);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/Vehicle.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* The vehicle used on a line.
*
* <p>See <a
* href="https://developers.google.com/maps/documentation/directions/intro#TransitDetails">Transit
* details</a> for more detail.
*/
public class Vehicle implements Serializable {
private static final long serialVersionUID = 1L;
/** The name of the vehicle on this line. E.g. {@code "Subway"}. */
public String name;
/**
* The type of vehicle that runs on this line. See the {@link VehicleType VehicleType}
* documentation for a complete list of supported values.
*/
public VehicleType type;
/** The URL for an icon associated with this vehicle type. */
public String icon;
/** The URL for an icon based on the local transport signage. */
public String localIcon;
@Override
public String toString() {
return String.format("%s (%s)", name, type);
}
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/VehicleType.java
|
/*
* Copyright 2015 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
/**
* The vehicle types.
*
* <p>See <a href="https://developers.google.com/maps/documentation/directions/intro#VehicleType">
* Vehicle Type</a> for more detail.
*/
public enum VehicleType {
/** Rail. */
RAIL,
/** Light rail transit. */
METRO_RAIL,
/** Underground light rail. */
SUBWAY,
/** Above ground light rail. */
TRAM,
/** Monorail. */
MONORAIL,
/** Heavy rail. */
HEAVY_RAIL,
/** Commuter rail. */
COMMUTER_TRAIN,
/** High speed train. */
HIGH_SPEED_TRAIN,
/** Bus. */
BUS,
/** Intercity bus. */
INTERCITY_BUS,
/** Trolleybus. */
TROLLEYBUS,
/**
* Share taxi is a kind of bus with the ability to drop off and pick up passengers anywhere on its
* route.
*/
SHARE_TAXI,
/** Ferry. */
FERRY,
/**
* A vehicle that operates on a cable, usually on the ground. Aerial cable cars may be of the type
* {@code GONDOLA_LIFT}.
*/
CABLE_CAR,
/** An aerial cable car. */
GONDOLA_LIFT,
/**
* A vehicle that is pulled up a steep incline by a cable. A Funicular typically consists of two
* cars, with each car acting as a counterweight for the other.
*/
FUNICULAR,
/** All other vehicles will return this type. */
OTHER
}
|
0
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps
|
java-sources/ai/nextbillion/nb-maps-client/1.7.1/ai/nextbillion/maps/model/WifiAccessPoint.java
|
/*
* Copyright 2016 Google Inc. All rights reserved.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
* file except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
* ANY KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package ai.nextbillion.maps.model;
import java.io.Serializable;
/**
* A WiFi access point.
*
* <p>The request body's {@code wifiAccessPoints} array must contain two or more WiFi access point
* objects. {@code macAddress} is required; all other fields are optional.
*
* <p>Please see <a
* href="https://developers.google.com/maps/documentation/geolocation/intro#wifi_access_point_object">
* WiFi Access Point Objects</a> for more detail.
*/
public class WifiAccessPoint implements Serializable {
private static final long serialVersionUID = 1L;
public WifiAccessPoint() {}
// constructor only used by the builder class below
private WifiAccessPoint(
String _macAddress,
Integer _signalStrength,
Integer _age,
Integer _channel,
Integer _signalToNoiseRatio) {
macAddress = _macAddress;
signalStrength = _signalStrength;
age = _age;
channel = _channel;
signalToNoiseRatio = _signalToNoiseRatio;
}
/**
* The MAC address of the WiFi node (required). Separators must be {@code :} (colon) and hex
* digits must use uppercase.
*/
public String macAddress;
/** The current signal strength measured in dBm. */
public Integer signalStrength = null;
/** The number of milliseconds since this access point was detected. */
public Integer age = null;
/** The channel over which the client is communicating with the access point. */
public Integer channel = null;
/** The current signal to noise ratio measured in dB. */
public Integer signalToNoiseRatio = null;
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[WifiAccessPoint:");
if (macAddress != null) {
sb.append(" macAddress=").append(macAddress);
}
if (signalStrength != null) {
sb.append(" signalStrength=").append(signalStrength);
}
if (age != null) {
sb.append(" age=").append(age);
}
if (channel != null) {
sb.append(" channel=").append(channel);
}
if (signalToNoiseRatio != null) {
sb.append(" signalToNoiseRatio=").append(signalToNoiseRatio);
}
sb.append("]");
return sb.toString();
}
public static class WifiAccessPointBuilder {
private String _macAddress = null;
private Integer _signalStrength = null;
private Integer _age = null;
private Integer _channel = null;
private Integer _signalToNoiseRatio = null;
// create the actual wifi access point
public WifiAccessPoint createWifiAccessPoint() {
return new WifiAccessPoint(_macAddress, _signalStrength, _age, _channel, _signalToNoiseRatio);
}
public WifiAccessPointBuilder MacAddress(String newMacAddress) {
this._macAddress = newMacAddress;
return this;
}
public WifiAccessPointBuilder SignalStrength(int newSignalStrength) {
this._signalStrength = newSignalStrength;
return this;
}
public WifiAccessPointBuilder Age(int newAge) {
this._age = newAge;
return this;
}
public WifiAccessPointBuilder Channel(int newChannel) {
this._channel = newChannel;
return this;
}
public WifiAccessPointBuilder SignalToNoiseRatio(int newSignalToNoiseRatio) {
this._signalToNoiseRatio = newSignalToNoiseRatio;
return this;
}
}
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/NBMapAPI.java
|
package ai.nextbillion.api;
import java.io.IOException;
import java.util.List;
import ai.nextbillion.api.directions.NBDirections;
import ai.nextbillion.api.directions.NBDirectionsResponse;
import ai.nextbillion.api.distancematrix.NBDistanceMatrix;
import ai.nextbillion.api.distancematrix.NBDistanceMatrixResponse;
import ai.nextbillion.api.models.NBLocation;
import ai.nextbillion.api.snaptoroad.NBSnapToRoad;
import ai.nextbillion.api.snaptoroad.NBSnapToRoadResponse;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class NBMapAPI {
private String key;
private String mode;
private String baseUrl;
private boolean debug = false;
private static class BillPughSingleton {
private static final NBMapAPI INSTANCE = new NBMapAPI();
}
public static NBMapAPI getInstance() {
return BillPughSingleton.INSTANCE;
}
public static NBMapAPI getInstance(String key, String baseUrl) {
NBMapAPI instance = BillPughSingleton.INSTANCE;
instance.setKey(key);
instance.setBaseUrl(baseUrl);
return instance;
}
public static NBMapAPI getDebugInstance() {
NBMapAPI instance = BillPughSingleton.INSTANCE;
instance.setKey("plaintesting");
instance.setMode("4w");
instance.setBaseUrl("https://api.nextbillion.io");
return instance;
}
private NBMapAPI() {
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getMode() {
return mode;
}
public void setMode(String mode) {
this.mode = mode;
}
public String getBaseUrl() {
return baseUrl;
}
public void setBaseUrl(String baseUrl) {
this.baseUrl = baseUrl;
}
public boolean isDebug() {
return debug;
}
public void setDebug(boolean debug) {
this.debug = debug;
}
///////////////////////////////////////////////////////////////////////////
// Directions
///////////////////////////////////////////////////////////////////////////
public Response<NBDirectionsResponse> getDirections(NBLocation origin, NBLocation destination) throws IOException {
int departureTime = (int) System.currentTimeMillis() / 1000;
NBDirections nbDirections = getDirectionsBuilder()
.origin(origin)
.destination(destination)
.departureTime(departureTime)
.build();
nbDirections.enableDebug(debug);
return nbDirections.executeCall();
}
public void enqueueGetDirections(NBLocation origin, NBLocation destination, Callback<NBDirectionsResponse> callback) {
int departureTime = (int) System.currentTimeMillis() / 1000;
NBDirections nbDirections = getDirectionsBuilder()
.origin(origin)
.destination(destination)
.departureTime(departureTime)
.build();
nbDirections.enableDebug(debug);
nbDirections.enqueueCall(callback);
}
public NBDirections.Builder getDirectionsBuilder() {
return NBDirections.builder()
.alternativeCount(1)
.alternatives(true)
.baseUrl(baseUrl)
.key(key)
.mode(mode)
.debug(debug)
.steps(true);
}
///////////////////////////////////////////////////////////////////////////
// Distance Matrix
///////////////////////////////////////////////////////////////////////////
public Response<NBDistanceMatrixResponse> getDistanceMatrix(List<NBLocation> origins, List<NBLocation> destinations) throws IOException {
NBDistanceMatrix distanceMatrix = getDistanceMatrixBuilder()
.origins(origins)
.destinations(destinations)
.departureTime((int) System.currentTimeMillis() / 1000)
.build();
distanceMatrix.enableDebug(debug);
return distanceMatrix.executeCall();
}
public void enqueueGetDistanceMatrix(List<NBLocation> origins, List<NBLocation> destinations, Callback<NBDistanceMatrixResponse> callback) {
NBDistanceMatrix distanceMatrix = getDistanceMatrixBuilder()
.origins(origins)
.destinations(destinations)
.departureTime((int) System.currentTimeMillis() / 1000)
.build();
distanceMatrix.enableDebug(debug);
distanceMatrix.enqueueCall(callback);
}
public NBDistanceMatrix.Builder getDistanceMatrixBuilder() {
return NBDistanceMatrix.builder()
.baseUrl(baseUrl)
.mode(mode)
.debug(debug)
.key(key);
}
///////////////////////////////////////////////////////////////////////////
// Matching / Snap To Roads
///////////////////////////////////////////////////////////////////////////
public Response<NBSnapToRoadResponse> getSnapToRoad(List<NBLocation> pointsOnPath) throws IOException {
NBSnapToRoad snapToRoad = getSnapToRoadBuilder()
.path(pointsOnPath)
.build();
snapToRoad.enableDebug(debug);
return snapToRoad.executeCall();
}
public void enqueueGetSnapToRoads(List<NBLocation> pointsOnPath, Callback<NBSnapToRoadResponse> callback) {
NBSnapToRoad snapToRoad = getSnapToRoadBuilder()
.path(pointsOnPath)
.build();
snapToRoad.enableDebug(debug);
snapToRoad.enqueueCall(callback);
}
public NBSnapToRoad.Builder getSnapToRoadBuilder() {
return NBSnapToRoad.builder()
.baseUrl(baseUrl)
.key(key)
.interpolate(true)
.tolerateOutlier(false);
}
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/package-info.java
|
/**
* Contains the Nbmap Java GeoJson classes.
*/
package ai.nextbillion.api;
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/directions/NBDirectionAdapterFactory.java
|
package ai.nextbillion.api.directions;
import com.google.gson.TypeAdapterFactory;
import com.ryanharter.auto.value.gson.GsonTypeAdapterFactory;
@GsonTypeAdapterFactory
public abstract class NBDirectionAdapterFactory implements TypeAdapterFactory {
public static TypeAdapterFactory create(){
return new AutoValueGson_NBDirectionAdapterFactory();
}
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/directions/NBDirections.java
|
package ai.nextbillion.api.directions;
import androidx.annotation.Nullable;
import com.google.auto.value.AutoValue;
import com.google.gson.GsonBuilder;
import com.nbmap.core.NbmapService;
import com.nbmap.core.constants.Constants;
import ai.nextbillion.api.models.NBLocation;
import retrofit2.Call;
@AutoValue
public abstract class NBDirections extends NbmapService<NBDirectionsResponse, NBDirectionsService> {
public NBDirections() {
super(NBDirectionsService.class);
}
@Override
protected abstract String baseUrl();
@Override
protected Call<NBDirectionsResponse> initializeCall() {
return get();
}
///////////////////////////////////////////////////////////////////////////
// HTTP
///////////////////////////////////////////////////////////////////////////
private Call<NBDirectionsResponse> get() {
return getService().getDirections(
alternativeCount(),
alternatives(),
debug(),
departureTime(),
destination().toString(),
geometry(),
key(),
mode(),
origin().toString(),
session(),
steps(),
wayPoints()
);
}
///////////////////////////////////////////////////////////////////////////
// Params
///////////////////////////////////////////////////////////////////////////
abstract int alternativeCount();
abstract boolean alternatives();
abstract boolean debug();
abstract int departureTime();
abstract NBLocation destination();
@Nullable
abstract String geometry();
abstract String key();
abstract String mode();
abstract NBLocation origin();
@Nullable
abstract String session();
abstract boolean steps();
@Nullable
abstract String wayPoints();
///////////////////////////////////////////////////////////////////////////
// Builder
///////////////////////////////////////////////////////////////////////////
@Override
protected GsonBuilder getGsonBuilder() {
return super.getGsonBuilder().registerTypeAdapterFactory(NBDirectionAdapterFactory.create());
}
public static Builder builder() {
return new AutoValue_NBDirections.Builder().baseUrl(Constants.BASE_API_URL);
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder baseUrl(String baseUrl);
public abstract Builder alternativeCount(int alternativeCount);
public abstract Builder alternatives(boolean alternatives);
public abstract Builder debug(boolean debug);
public abstract Builder departureTime(int departureTime);
public abstract Builder destination(NBLocation destination);
public abstract Builder geometry(String geometry);
public abstract Builder key(String key);
public abstract Builder mode(String mode);
public abstract Builder origin(NBLocation origin);
public abstract Builder session(String session);
public abstract Builder steps(boolean steps);
public abstract Builder wayPoints(String wayPoints);
public abstract NBDirections build();
}
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/directions/NBDirectionsResponse.java
|
package ai.nextbillion.api.directions;
import androidx.annotation.Nullable;
import com.google.auto.value.AutoValue;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import java.io.Serializable;
import java.util.List;
import ai.nextbillion.api.models.directions.NBRoute;
@AutoValue
public abstract class NBDirectionsResponse implements Serializable {
///////////////////////////////////////////////////////////////////////////
// Params
///////////////////////////////////////////////////////////////////////////
@Nullable
public abstract String errorMessage();
@Nullable
public abstract String mode();
@Nullable
public abstract String status();
public abstract List<NBRoute> routes();
///////////////////////////////////////////////////////////////////////////
// Params end
///////////////////////////////////////////////////////////////////////////
public static Builder builder() {
return new AutoValue_NBDirectionsResponse.Builder();
}
public abstract Builder toBuilder();
public static TypeAdapter<NBDirectionsResponse> typeAdapter(Gson gson) {
return new AutoValue_NBDirectionsResponse.GsonTypeAdapter(gson);
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder errorMessage(String errorMessage);
public abstract Builder mode(String mode);
public abstract Builder status(String status);
public abstract Builder routes(List<NBRoute> routes);
public abstract NBDirectionsResponse build();
}
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/directions/NBDirectionsResponseFactory.java
|
package ai.nextbillion.api.directions;
public class NBDirectionsResponseFactory {
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/directions/NBDirectionsService.java
|
package ai.nextbillion.api.directions;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
public interface NBDirectionsService {
//context is deprecated
//special object types is for L&T only
@GET("/directions/json")
Call<NBDirectionsResponse> getDirections(
@Query("altcount") int alternativeCount,
@Query("alternatives") boolean alternatives,
@Query("debug") boolean debug,
@Query("departure_time") int departureTime,
@Query("destination") String destination,
@Query("geometry") String geometry,
@Query("key") String key,
@Query("mode") String mode,
@Query("origin") String origin,
@Query("session") String session,
@Query("steps") boolean steps,
@Query("waypoints") String wayPoints
);
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/directions/package-info.java
|
/**
* Contains the constants used throughout the GeoJson classes.
*/
package ai.nextbillion.api.directions;
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/distancematrix/NBDistanceMatrix.java
|
package ai.nextbillion.api.distancematrix;
import androidx.annotation.NonNull;
import com.google.auto.value.AutoValue;
import com.google.gson.GsonBuilder;
import com.nbmap.core.NbmapService;
import com.nbmap.core.constants.Constants;
import java.util.List;
import ai.nextbillion.api.models.NBLocation;
import ai.nextbillion.api.utils.FormatUtils;
import retrofit2.Call;
@AutoValue
public abstract class NBDistanceMatrix extends NbmapService<NBDistanceMatrixResponse, NBDistanceMatrixService> {
public NBDistanceMatrix() {
super(NBDistanceMatrixService.class);
}
@Override
protected abstract String baseUrl();
@Override
protected Call<NBDistanceMatrixResponse> initializeCall() {
return getService().getDistanceMatrix(
debug(),
departureTime(),
locationsToString(destinations()),
key(),
mode(),
locationsToString(origins())
);
}
///////////////////////////////////////////////////////////////////////////
// Params converter
///////////////////////////////////////////////////////////////////////////
private String locationsToString(@NonNull List<NBLocation> locations) {
return FormatUtils.join("|", locations);
}
///////////////////////////////////////////////////////////////////////////
// Params
///////////////////////////////////////////////////////////////////////////
abstract boolean debug();
abstract int departureTime();
abstract List<NBLocation> destinations();
abstract String key();
abstract String mode();
abstract List<NBLocation> origins();
///////////////////////////////////////////////////////////////////////////
// Builder
///////////////////////////////////////////////////////////////////////////
@Override
protected GsonBuilder getGsonBuilder() {
return super.getGsonBuilder().registerTypeAdapterFactory(NBDistanceMatrixAdapterFactory.create());
}
public static Builder builder() {
return new AutoValue_NBDistanceMatrix.Builder().baseUrl(Constants.BASE_API_URL);
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder baseUrl(String baseUrl);
public abstract Builder debug(boolean debug);
public abstract Builder departureTime(int departureTime);
public abstract Builder destinations(List<NBLocation> destinations);
public abstract Builder key(String accessToken);
public abstract Builder mode(String mode);
public abstract Builder origins(List<NBLocation> origins);
public abstract NBDistanceMatrix build();
}
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/distancematrix/NBDistanceMatrixAdapterFactory.java
|
package ai.nextbillion.api.distancematrix;
import com.google.gson.TypeAdapterFactory;
import com.ryanharter.auto.value.gson.GsonTypeAdapterFactory;
@GsonTypeAdapterFactory
public abstract class NBDistanceMatrixAdapterFactory implements TypeAdapterFactory {
public static TypeAdapterFactory create(){
return new AutoValueGson_NBDistanceMatrixAdapterFactory();
}
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/distancematrix/NBDistanceMatrixResponse.java
|
package ai.nextbillion.api.distancematrix;
import com.google.auto.value.AutoValue;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import java.util.List;
import ai.nextbillion.api.models.NBDistanceMatrixRow;
@AutoValue
public abstract class NBDistanceMatrixResponse {
///////////////////////////////////////////////////////////////////////////
// Params
///////////////////////////////////////////////////////////////////////////
public abstract String status();
public abstract List<NBDistanceMatrixRow> rows();
///////////////////////////////////////////////////////////////////////////
// Params end
///////////////////////////////////////////////////////////////////////////
public static TypeAdapter<NBDistanceMatrixResponse> typeAdapter(Gson gson) {
return new AutoValue_NBDistanceMatrixResponse.GsonTypeAdapter(gson);
}
public static Builder builder() {
return new AutoValue_NBDistanceMatrixResponse.Builder();
}
public abstract Builder toBuilder();
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder status(String status);
public abstract Builder rows(List<NBDistanceMatrixRow> rows);
public abstract NBDistanceMatrixResponse build();
}
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/distancematrix/NBDistanceMatrixResponseFactory.java
|
package ai.nextbillion.api.distancematrix;
public class NBDistanceMatrixResponseFactory {
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/distancematrix/NBDistanceMatrixService.java
|
package ai.nextbillion.api.distancematrix;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
public interface NBDistanceMatrixService {
@GET("/distancematrix/json")
Call<NBDistanceMatrixResponse> getDistanceMatrix(
@Query("debug") boolean debug,
@Query("departure_time") int departureTime,
@Query("destinations") String destinations,
@Query("key") String accessToken,
@Query("mode") String mode,
@Query("origins") String origins
);
@FormUrlEncoded
@POST("/distancematrix/json")
Call<NBDistanceMatrixResponse> postDistanceMatrix(
@Field("debug") boolean debug,
@Field("departure_time") int departureTime,
@Field("destinations") String destinations,
@Field("key") String accessToken,
@Field("mode") String mode,
@Field("origins") String origins
);
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/distancematrix/package-info.java
|
/**
* Contains the constants used throughout the GeoJson classes.
*/
package ai.nextbillion.api.distancematrix;
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/NBDistance.java
|
package ai.nextbillion.api.models;
import androidx.annotation.Keep;
@Keep
public class NBDistance {
public int value;
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/NBDistanceMatrixItem.java
|
package ai.nextbillion.api.models;
import com.google.auto.value.AutoValue;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
@AutoValue
public abstract class NBDistanceMatrixItem {
public abstract NBDistance distance();
public abstract NBDuration duration();
public static TypeAdapter<NBDistanceMatrixItem> typeAdapter(Gson gson) {
return new AutoValue_NBDistanceMatrixItem.GsonTypeAdapter(gson);
}
public static Builder builder() {
return new AutoValue_NBDistanceMatrixItem.Builder();
}
public abstract Builder toBuilder();
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder distance(NBDistance distance);
public abstract Builder duration(NBDuration duration);
public abstract NBDistanceMatrixItem build();
}
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/NBDistanceMatrixRow.java
|
package ai.nextbillion.api.models;
import androidx.annotation.Keep;
import java.util.List;
@Keep
public class NBDistanceMatrixRow {
public List<NBDistanceMatrixItem> elements;
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/NBDuration.java
|
package ai.nextbillion.api.models;
import androidx.annotation.Keep;
@Keep
public class NBDuration {
public int value;
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/NBLocation.java
|
package ai.nextbillion.api.models;
public class NBLocation {
public NBLocation(double latitude, double longitude) {
this.latitude = latitude;
this.longitude = longitude;
}
public double latitude;
public double longitude;
@Override
public String toString() {
return latitude +
"," + longitude;
}
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/NBNearByObject.java
|
package ai.nextbillion.api.models;
public class NBNearByObject {
public int distance;
public long eta;
public String id;
public NBLocation location;
public NBNearByObject(int distance, long eta, String id, NBLocation location) {
this.distance = distance;
this.eta = eta;
this.id = id;
this.location = location;
}
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/NBSimpleRoute.java
|
package ai.nextbillion.api.models;
import androidx.annotation.Keep;
@Keep
public class NBSimpleRoute {
public double distance;
public String geometry;
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/NBSnappedPoint.java
|
package ai.nextbillion.api.models;
public class NBSnappedPoint {
public double bearing;
public double distance;
public int originalIndex;
public String name;
public NBLocation location;
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/NBSpecialObject.java
|
package ai.nextbillion.api.models;
public class NBSpecialObject {
}
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/package-info.java
|
/**
* Contains the constants used throughout the GeoJson classes.
*/
package ai.nextbillion.api.models;
|
0
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models
|
java-sources/ai/nextbillion/nbmap-sdk-api/0.1.2/ai/nextbillion/api/models/directions/NBLegStep.java
|
package ai.nextbillion.api.models.directions;
import androidx.annotation.Nullable;
import com.google.auto.value.AutoValue;
import com.google.gson.Gson;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.SerializedName;
import ai.nextbillion.api.models.NBLocation;
@AutoValue
public abstract class NBLegStep {
@Nullable
@SerializedName("end_location")
public abstract NBLocation endLocation();
@Nullable
@SerializedName("start_location")
public abstract NBLocation startLocation();
@Nullable
public abstract String geometry();
public static TypeAdapter<NBLegStep> typeAdapter(Gson gson) {
return new AutoValue_NBLegStep.GsonTypeAdapter(gson);
}
public static Builder builder() {
return new AutoValue_NBLegStep.Builder();
}
public abstract Builder toBuilder();
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder endLocation(NBLocation endLocation);
public abstract Builder startLocation(NBLocation startLocation);
public abstract Builder geometry(String geometry);
public abstract NBLegStep build();
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.