List of usage examples for com.google.common.collect Lists reverse
@CheckReturnValue public static <T> List<T> reverse(List<T> list)
From source file:com.google.api.codegen.metacode.InitCodeNode.java
public List<InitCodeNode> listInInitializationOrder() { ArrayList<InitCodeNode> initOrder = new ArrayList<>(); ArrayDeque<InitCodeNode> initStack = new ArrayDeque<>(); initStack.add(this); while (!initStack.isEmpty()) { InitCodeNode node = initStack.pollLast(); initStack.addAll(node.children.values()); initOrder.add(node);//from www .ja v a2 s . c o m } return Lists.reverse(initOrder); }
From source file:org.ballerinalang.composer.service.workspace.swagger.SwaggerServiceMapper.java
/** * Parses the 'ServiceConfig' annotation attachment. * @param service The ballerina service which has that annotation attachment. * @param swagger The swagger definition to build up. *//* w w w .ja va 2s . c om*/ private void parseServiceConfigAnnotationAttachment(ServiceNode service, Swagger swagger) { Optional<? extends AnnotationAttachmentNode> swaggerConfigAnnotation = service.getAnnotationAttachments() .stream() .filter(a -> null != swaggerAlias && this.swaggerAlias.equals(a.getPackageAlias().getValue()) && "ServiceConfig".equals(a.getAnnotationName().getValue())) .findFirst(); if (swaggerConfigAnnotation.isPresent()) { Map<String, AnnotationAttachmentAttributeValueNode> serviceConfigAttributes = this .listToMap(swaggerConfigAnnotation.get()); if (serviceConfigAttributes.containsKey("host")) { swagger.setHost(this.getStringLiteralValue(serviceConfigAttributes.get("host"))); } if (serviceConfigAttributes.containsKey("schemes") && serviceConfigAttributes.get("schemes").getValueArray().size() > 0) { List<Scheme> schemes = new LinkedList<>(); for (AnnotationAttachmentAttributeValueNode schemesNodes : serviceConfigAttributes.get("schemes") .getValueArray()) { String schemeStringValue = this.getStringLiteralValue(schemesNodes); if (null != Scheme.forValue(schemeStringValue)) { schemes.add(Scheme.forValue(schemeStringValue)); } } if (schemes.size() > 0) { schemes = Lists.reverse(schemes); swagger.setSchemes(schemes); } } this.createSecurityDefinitionsModel(serviceConfigAttributes.get("authorizations"), swagger); } }
From source file:gobblin.runtime.template.InheritingJobTemplate.java
private Config getResolvedConfigHelper(Config userConfig, Set<JobTemplate> alreadyLoadedTemplates) throws SpecNotFoundException, TemplateException { Config config = getLocallyResolvedConfig(userConfig); for (JobTemplate template : Lists.reverse(this.superTemplates)) { if (!alreadyLoadedTemplates.contains(template)) { alreadyLoadedTemplates.add(template); Config fallback = template instanceof InheritingJobTemplate ? ((InheritingJobTemplate) template).getResolvedConfigHelper(config, alreadyLoadedTemplates) : template.getResolvedConfig(config); config = config.withFallback(fallback); }/*from w w w . j a v a 2 s .co m*/ } return config; }
From source file:org.activityinfo.ui.client.page.entry.location.LocationMap.java
private void updateSearchMarkers() { markerLayer.clearLayers();//from ww w . j a v a2s. c o m List<LocationDTO> locations = Lists.reverse(searchPresenter.getStore().getModels()); LatLngBounds bounds = new LatLngBounds(); boolean empty = true; for (LocationDTO location : locations) { if (location.hasCoordinates()) { LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude()); Marker marker = createMarker(latLng, location.getMarker()); markerLayer.addLayer(marker); bounds.extend(latLng); bindClickEvent(location, marker); empty = false; } } if (!empty) { updateMap(bounds); } }
From source file:ch.ge.ve.protopoc.service.algorithm.PolynomialAlgorithms.java
/** * Algorithm 7.9: GetYValue/*from www. j a v a 2s . com*/ * <p>Generates the coefficients a_0, ..., a_d of a random polynomial</p> * * @param x value in Z_p_prime * @param bold_a the coefficients of the polynomial * @return the computed value y */ public BigInteger getYValue(BigInteger x, List<BigInteger> bold_a) { Preconditions.checkArgument(bold_a.size() >= 1, String .format("The size of bold_a should always be larger or equal to 1 (it is [%d]", bold_a.size())); if (x.equals(BigInteger.ZERO)) { return bold_a.get(0); } else { BigInteger y = BigInteger.ZERO; for (BigInteger a_i : Lists.reverse(bold_a)) { y = a_i.add(x.multiply(y).mod(primeField.getP_prime())).mod(primeField.getP_prime()); } return y; } }
From source file:io.crate.operation.collect.ShardProjectorChain.java
public void startProjections() { for (Projector projector : Lists.reverse(nodeProjectors)) { projector.startProjection();/* ww w. j a v a 2 s . c o m*/ } if (shardProjectionsIndex >= 0) { for (Projector p : shardProjectors) { p.startProjection(); } } }
From source file:com.spotify.helios.serviceregistration.skydns.SkyDnsServiceRegistrar.java
private static String pathifyDomain(final String domain) { final List<String> constituents = Splitter.on('.').omitEmptyStrings().splitToList(domain); return Joiner.on('/').join(Lists.reverse(constituents)); }
From source file:brooklyn.entity.mesos.task.marathon.MarathonTaskImpl.java
@Override public void init() { super.init(); ConfigToAttributes.apply(this, ENTITY); String id = null;// w w w . j a v a 2s.c om if (sensors().get(MANAGED)) { id = getMarathonApplicationId(); String name = Joiner.on('.').join(Lists.reverse(Splitter.on('/').omitEmptyStrings().splitToList(id))); sensors().set(APPLICATION_ID, id); sensors().set(TASK_NAME, name); } else { String name = sensors().get(TASK_NAME); id = "/" + name; sensors().set(APPLICATION_ID, id); } LOG.info("Marathon task {} for: {}", id, sensors().get(ENTITY)); }
From source file:org.sonar.java.cfg.CFG.java
public List<Block> blocks() { return Lists.reverse(blocks); }
From source file:com.google.devtools.build.lib.rules.config.ConfigSetting.java
/** * For single-value options, returns true iff the option's value matches the expected value. * * <p>For multi-value List options, returns true iff any of the option's values matches the * expected value. This means, e.g. "--tool_tag=foo --tool_tag=bar" would match the expected * condition { 'tool_tag': 'bar' }.//from w w w . ja va 2 s .co m * * <p>For multi-value Map options, returns true iff the last instance with the same key as the * expected key has the same value. This means, e.g. "--define foo=1 --define bar=2" would match { * 'define': 'foo=1' }, but "--define foo=1 --define bar=2 --define foo=3" would not match. Note * that the definition of --define states that the last instance takes precedence. */ private static boolean optionMatches(TransitiveOptionDetails options, String optionName, Object expectedValue) { Object actualValue = options.getOptionValue(optionName); if (actualValue == null) { return expectedValue == null; // Single-value case: } else if (!options.allowsMultipleValues(optionName)) { return actualValue.equals(expectedValue); } // Multi-value case: Preconditions.checkState(actualValue instanceof List); Preconditions.checkState(expectedValue instanceof List); List<?> actualList = (List<?>) actualValue; List<?> expectedList = (List<?>) expectedValue; if (actualList.isEmpty() || expectedList.isEmpty()) { return actualList.isEmpty() && expectedList.isEmpty(); } // We're expecting a single value of a multi-value type: the options parser still embeds // that single value within a List container. Retrieve it here. Object expectedSingleValue = Iterables.getOnlyElement(expectedList); // Multi-value map: if (actualList.get(0) instanceof Map.Entry) { Map.Entry<?, ?> expectedEntry = (Map.Entry<?, ?>) expectedSingleValue; for (Map.Entry<?, ?> actualEntry : Lists.reverse((List<Map.Entry<?, ?>>) actualList)) { if (actualEntry.getKey().equals(expectedEntry.getKey())) { // Found a key match! return actualEntry.getValue().equals(expectedEntry.getValue()); } } return false; // Never found any matching key. } // Multi-value list: return actualList.contains(expectedSingleValue); }