/** * Factory method to create an unmodifiable list. * * @param <E> the type of the elements in the list * @param list the list to decorate, must not be null * @return a new unmodifiable list * @throws NullPointerException if list is null * @since 4.0 */ public static <E> List<E> unmodifiableList(final List<? extends E> list) { if (list instanceof Unmodifiable) { @SuppressWarnings("unchecked") // safe to upcast final List<E> tmpList = (List<E>) list; return tmpList; } return new UnmodifiableList<>(list); }
/** * Gets an unmodifiable view of the order of the Set. * * @return an unmodifiable list view */ public List<E> asList() { return UnmodifiableList.unmodifiableList(setOrder); }
@Override public List<E> subList(final int fromIndex, final int toIndex) { final List<E> sub = decorated().subList(fromIndex, toIndex); return new UnmodifiableList<>(sub); }
if(this.enableEndpointDiscovery && currentLocationInfo.availableWriteLocations.size() > 0) { locationIndex = Math.min(locationIndex%2, currentLocationInfo.availableWriteLocations.size()-1); String writeLocation = currentLocationInfo.availableWriteLocations.get(locationIndex); return currentLocationInfo.availableWriteEndpointByLocation.get(writeLocation); } else { return endpoints.get(locationIndex % endpoints.size());
@Override public ListIterator<E> listIterator(final int index) { return UnmodifiableListIterator.umodifiableListIterator(decorated().listIterator(index)); }
private URI getUri(RxDocumentServiceRequest request) throws URISyntaxException { URI rootUri = request.getEndpointOverride(); if (rootUri == null) { if (request.getIsMedia()) { // For media read request, always use the write endpoint. rootUri = this.globalEndpointManager.getWriteEndpoints().get(0).toURI(); } else { rootUri = this.globalEndpointManager.resolveServiceEndpoint(request).toURI(); } } URI uri = new URI("https", null, rootUri.getHost(), rootUri.getPort(), ensureSlashPrefixed(request.getPath()), null, // Query string not used. null); return uri; }
private ShouldRetryResult shouldRetryOnSessionNotAvailable() { this.sessionTokenRetryCount++; if (!this.enableEndpointDiscovery) { // if endpoint discovery is disabled, the request cannot be retried anywhere else return ShouldRetryResult.noRetry(); } else { if (this.canUseMultipleWriteLocations) { UnmodifiableList<URL> endpoints = this.isReadRequest ? this.globalEndpointManager.getReadEndpoints() : this.globalEndpointManager.getWriteEndpoints(); if (this.sessionTokenRetryCount > endpoints.size()) { // When use multiple write locations is true and the request has been tried // on all locations, then don't retry the request return ShouldRetryResult.noRetry(); } else { this.retryContext = new RetryContext(this.sessionTokenRetryCount - 1, this.sessionTokenRetryCount > 1,this.sessionTokenRetryCount == endpoints.size()); return ShouldRetryResult.retryAfter(Duration.ZERO); } } else { if (this.sessionTokenRetryCount > 1) { // When cannot use multiple write locations, then don't retry the request if // we have already tried this request on the write location return ShouldRetryResult.noRetry(); } else { this.retryContext = new RetryContext(this.sessionTokenRetryCount - 1, false, true); return ShouldRetryResult.retryAfter(Duration.ZERO); } } } }
@Override public ListIterator<E> listIterator() { return UnmodifiableListIterator.umodifiableListIterator(decorated().listIterator()); }
nextLocationInfo.readEndpoints = this.getPreferredAvailableEndpoints(nextLocationInfo.availableReadEndpointByLocation, nextLocationInfo.availableReadLocations, OperationType.Read, nextLocationInfo.writeEndpoints.get(0)); this.lastCacheUpdateTimestamp = Instant.now();
/** * Constructor for setting the intended class and fields of the target bean. * These may not be known in every context. * * @param beanClass Class of the destination bean * @param destinationFields Fields of the destination fields in the destination bean * @since 4.2 */ public CsvRequiredFieldEmptyException(Class<?> beanClass, List<Field> destinationFields) { this.beanClass = beanClass; this.destinationFields = new UnmodifiableList<>(destinationFields); }
/** * Returns an unmodifiable list backed by the given list. * <p> * This method uses the implementation in the decorators subpackage. * * @param <E> the element type * @param list the list to make unmodifiable, must not be null * @return an unmodifiable list backed by the given list * @throws NullPointerException if the list is null */ public static <E> List<E> unmodifiableList(final List<? extends E> list) { return UnmodifiableList.unmodifiableList(list); }
@Override public Iterator<E> iterator() { return UnmodifiableIterator.unmodifiableIterator(decorated().iterator()); }
public List<LocalVariable> getVariables() { return new UnmodifiableList<LocalVariable>(variables); } }
/** * Gets the collections being decorated. * * @return Unmodifiable list of all collections in this composite. */ public List<Collection<E>> getCollections() { return UnmodifiableList.unmodifiableList(all); }
public SystemInfo(String hostName, String user, Long pid, List<String> publicKeys, String osName, int numCpus) { this.hostName = hostName; this.user = user; this.pid = pid; this.publicKeys = new UnmodifiableList<>(publicKeys); this.osName = osName; this.numCpus = numCpus; }
/** * Gets the sets being decorated. * * @return Unmodifiable list of all sets in this composite. */ public List<Set<E>> getSets() { return UnmodifiableList.unmodifiableList(all); }
public List<DJGroupVariable> getHeaderVariables() { return new UnmodifiableList<DJGroupVariable>(headerVariables); }
/** * Gets the list of Iterators (unmodifiable). * * @return the unmodifiable list of iterators added */ public List<Iterator<? extends E>> getIterators() { return UnmodifiableList.unmodifiableList(iterators); }
public List<DJGroupVariable> getHeaderVariables() { return new UnmodifiableList<DJGroupVariable>(headerVariables); }
/** * Gets a view over the keys in the map as a List. * <p> * The List will be ordered by object insertion into the map. * The List is unmodifiable. * * @see #keySet() * @return the unmodifiable list view over the keys * @since 3.2 */ public List<K> keyList() { return UnmodifiableList.unmodifiableList(insertOrder); }