List of usage examples for com.google.common.collect ImmutableList size
int size();
From source file:org.glowroot.local.ui.GaugeJsonService.java
@GET("/backend/config/matching-mbean-objects") String getMatchingMBeanObjects(String queryString) throws Exception { MBeanObjectNameRequest request = QueryStrings.decode(queryString, MBeanObjectNameRequest.class); Set<ObjectName> objectNames = lazyPlatformMBeanServer.queryNames(null, new ObjectNameQueryExp(request.partialMBeanObjectName())); List<String> names = Lists.newArrayList(); for (ObjectName objectName : objectNames) { names.add(objectName.toString()); }/*from www.j av a2 s .com*/ ImmutableList<String> sortedNames = Ordering.from(String.CASE_INSENSITIVE_ORDER).immutableSortedCopy(names); if (sortedNames.size() > request.limit()) { sortedNames = sortedNames.subList(0, request.limit()); } return mapper.writeValueAsString(sortedNames); }
From source file:com.facebook.presto.operator.scalar.Least.java
@Override public FunctionInfo specialize(Map<String, Type> types, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { Type type = types.get("E"); checkArgument(type.isOrderable(), "Type must be orderable"); ImmutableList.Builder<Class<?>> builder = ImmutableList.builder(); for (int i = 0; i < arity; i++) { builder.add(type.getJavaType()); }/*from ww w.j a v a 2 s . co m*/ ImmutableList<Class<?>> stackTypes = builder.build(); Class<?> clazz = generateLeast(stackTypes, type); MethodHandle methodHandle = methodHandle(clazz, "least", stackTypes.toArray(new Class<?>[stackTypes.size()])); List<Boolean> nullableParameters = ImmutableList.copyOf(Collections.nCopies(stackTypes.size(), false)); Signature specializedSignature = internalFunction(SIGNATURE.getName(), type.getTypeSignature(), Collections.nCopies(arity, type.getTypeSignature())); return new FunctionInfo(specializedSignature, getDescription(), isHidden(), methodHandle, isDeterministic(), false, nullableParameters); }
From source file:net.osten.watermap.convert.SanMateoWildernessReport.java
/** * Returns water reports from text file. * Text file format: name, description, state, last report, reported by, lat, lon. * * @return set of water reports//from w w w .j a va2s . co m */ public Set<WaterReport> convert() { Set<WaterReport> results = new HashSet<WaterReport>(); int lineNumber = 1; try { log.info("opening filePath=" + filePath); ImmutableList<String> lines = filePath != null ? Files.asCharSource(new File(filePath), Charsets.UTF_8).readLines() : Resources.asCharSource(fileURL, Charsets.UTF_8).readLines(); log.fine("found " + lines.size() + " lines"); for (String line : lines) { // find start of data line section WaterReport wr = null; log.fine("parsing line[" + lineNumber + "]=" + line); wr = parseDataLine(line); if (wr != null && wr.getName() != null) { log.fine("adding wr=" + wr); boolean added = results.add(wr); if (!added) { results.remove(wr); results.add(wr); } } else { log.finer("did not add wr for line " + lineNumber); } lineNumber++; } } catch (IOException e) { log.severe(e.getLocalizedMessage()); } return results; }
From source file:org.eclipse.xtext.builder.impl.QueuedBuildData.java
private IQueuedBuildDataContribution getContribution( ImmutableList<? extends IQueuedBuildDataContribution> contributions) { switch (contributions.size()) { case 0:/*from w ww . ja v a 2 s. c om*/ return new NullContribution(); case 1: return contributions.get(0); default: return new CompositeContribution(contributions); } }
From source file:org.eclipse.xtext.builder.impl.ToBeBuiltComputer.java
private IToBeBuiltComputerContribution getContribution( ImmutableList<? extends IToBeBuiltComputerContribution> contributedInstances) { switch (contributedInstances.size()) { case 0:/*w w w . j a va 2s. c om*/ return new NullContribution(); case 1: return contributedInstances.get(0); default: return new CompositeContribution(contributedInstances); } }
From source file:org.locationtech.geogig.plumbing.diff.Patch.java
private String featureTypeDiffAsString(FeatureTypeDiff diff) { StringBuilder sb = new StringBuilder(); sb.append(diff.toString() + "\n"); if (!diff.getNewFeatureType().equals(ObjectId.NULL) && !diff.getOldFeatureType().equals(ObjectId.NULL)) { RevFeatureType oldFeatureType = getFeatureTypeFromId(diff.getOldFeatureType()).get(); RevFeatureType newFeatureType = getFeatureTypeFromId(diff.getNewFeatureType()).get(); ImmutableList<PropertyDescriptor> oldDescriptors = oldFeatureType.descriptors(); ImmutableList<PropertyDescriptor> newDescriptors = newFeatureType.descriptors(); BitSet updatedDescriptors = new BitSet(newDescriptors.size()); for (int i = 0; i < oldDescriptors.size(); i++) { PropertyDescriptor oldDescriptor = oldDescriptors.get(i); int idx = newDescriptors.indexOf(oldDescriptor); if (idx != -1) { updatedDescriptors.set(idx); } else { Class<?> oldType = oldDescriptor.getType().getBinding(); sb.append(/* ww w . j a va 2 s . c o m*/ "R\t" + oldDescriptors.get(i).getName().getLocalPart() + "[" + oldType.getName() + "]"); } } updatedDescriptors.flip(0, updatedDescriptors.length()); for (int i = updatedDescriptors.nextSetBit(0); i >= 0; i = updatedDescriptors.nextSetBit(i + 1)) { PropertyDescriptor newDescriptor = newDescriptors.get(i); Class<?> oldType = newDescriptor.getType().getBinding(); sb.append("A\t" + newDescriptors.get(i).getName().getLocalPart() + "[" + oldType.getName() + "]"); } } return sb.toString(); }
From source file:com.google.api.codegen.java.JavaGapicContext.java
public String partitionKeyCode(ImmutableList<FieldSelector> discriminatorFields) { StringBuffer buf = new StringBuffer(); for (int i = 0; i < discriminatorFields.size(); i++) { if (i > 0) { buf.append(" + \"|\" + "); }/*from ww w . j av a 2 s . co m*/ String simpleName = discriminatorFields.get(i).getLastField().getSimpleName(); buf.append("request.get" + lowerUnderscoreToUpperCamel(simpleName) + "()"); } return buf.toString(); }
From source file:org.locationtech.geogig.plumbing.diff.FeatureDiff.java
/** * //from w ww .j av a 2s .com * @param path the full path to the feature, including its name * @param newRevFeature the new version of the feature * @param oldRevFeature the old version of the feature * @param newRevFeatureType the new version of the feature type * @param oldRevFeatureType the old version of the feature type * @param all - true if all attributes should be added regardless of change */ public FeatureDiff(String path, @Nullable RevFeature newRevFeature, @Nullable RevFeature oldRevFeature, @Nullable RevFeatureType newRevFeatureType, @Nullable RevFeatureType oldRevFeatureType, boolean all) { this.path = path; this.newRevFeature = newRevFeature; this.oldRevFeature = oldRevFeature; this.newFeatureType = newRevFeatureType; this.oldFeatureType = oldRevFeatureType; diffs = new HashMap<PropertyDescriptor, AttributeDiff>(); if (newRevFeature == null) { Preconditions.checkArgument(oldRevFeature != null, "A feature must be provided"); Preconditions.checkArgument(oldRevFeatureType != null, "Old feature type must be provided."); ImmutableList<PropertyDescriptor> oldAttributes = oldRevFeatureType.descriptors(); for (int i = 0; i < oldAttributes.size(); i++) { Optional<Object> oldValue = oldRevFeature.get(i); PropertyDescriptor descriptor = oldAttributes.get(i); if (Geometry.class.isAssignableFrom(descriptor.getType().getBinding())) { diffs.put(descriptor, new GeometryAttributeDiff((Geometry) oldValue.orNull(), (Geometry) null)); } else { diffs.put(oldAttributes.get(i), new GenericAttributeDiffImpl(oldValue.orNull(), null)); } } } else if (oldRevFeature == null) { Preconditions.checkArgument(newRevFeatureType != null, "New feature type must be provided."); ImmutableList<PropertyDescriptor> newAttributes = newRevFeatureType.descriptors(); for (int i = 0; i < newAttributes.size(); i++) { Optional<Object> newValue = newRevFeature.get(i); PropertyDescriptor descriptor = newAttributes.get(i); if (Geometry.class.isAssignableFrom(descriptor.getType().getBinding())) { diffs.put(descriptor, new GeometryAttributeDiff((Geometry) null, (Geometry) newValue.orNull())); } else { diffs.put(newAttributes.get(i), new GenericAttributeDiffImpl(null, newValue.orNull())); } } } else { ImmutableList<PropertyDescriptor> oldAttributes = oldRevFeatureType.descriptors(); ImmutableList<PropertyDescriptor> newAttributes = newRevFeatureType.descriptors(); BitSet updatedAttributes = new BitSet(newRevFeature.size()); for (int i = 0; i < oldAttributes.size(); i++) { Optional<Object> oldValue = oldRevFeature.get(i); int idx = newAttributes.indexOf(oldAttributes.get(i)); if (idx != -1) { Optional<Object> newValue = newRevFeature.get(idx); if (!oldValue.equals(newValue) || all) { if (Geometry.class.isAssignableFrom(oldAttributes.get(i).getType().getBinding())) { diffs.put(oldAttributes.get(i), new GeometryAttributeDiff((Geometry) oldValue.orNull(), (Geometry) newValue.orNull())); } else { diffs.put(oldAttributes.get(i), new GenericAttributeDiffImpl(oldValue.orNull(), newValue.orNull())); } } updatedAttributes.set(idx); } else { if (Geometry.class.isAssignableFrom(oldAttributes.get(i).getType().getBinding())) { diffs.put(oldAttributes.get(i), new GeometryAttributeDiff((Geometry) oldValue.orNull(), (Geometry) null)); } else { diffs.put(oldAttributes.get(i), new GenericAttributeDiffImpl(oldValue.orNull(), null)); } } } updatedAttributes.flip(0, newRevFeature.size()); for (int i = updatedAttributes.nextSetBit(0); i >= 0; i = updatedAttributes.nextSetBit(i + 1)) { PropertyDescriptor descriptor = newAttributes.get(i); if (Geometry.class.isAssignableFrom(descriptor.getType().getBinding())) { diffs.put(descriptor, new GeometryAttributeDiff((Geometry) null, (Geometry) newRevFeature.get(i).orNull())); } else { diffs.put(descriptor, new GenericAttributeDiffImpl(null, newRevFeature.get(i).orNull())); } } } }
From source file:ru.adios.budgeter.adapters.RefreshingAdapter.java
private void processRefreshResultInner(ImmutableList<Type> data, @Nullable Param param, boolean wasRestore) { refreshCommencing = false;// w w w .j a va2 s. c o m if (data != null && data.size() > 0) { currentParam = param; } if (data != null && data.size() > 0) { this.items = data; if (wasRestore) { if (onRestoreListener != null) { onRestoreListener.onRestoredState(); } } else { if (onRefreshListener != null) { onRefreshListener.onRefreshed(); } } notifyDataSetChanged(); } else { if (onRefreshListener != null) { onRefreshListener.onNoDataLoaded(); } } }
From source file:org.geogit.api.plumbing.diff.Patch.java
private String featureTypeDiffAsString(FeatureTypeDiff diff) { StringBuilder sb = new StringBuilder(); sb.append(diff.toString() + "\n"); if (!diff.getNewFeatureType().equals(ObjectId.NULL) && !diff.getOldFeatureType().equals(ObjectId.NULL)) { RevFeatureType oldFeatureType = getFeatureTypeFromId(diff.getOldFeatureType()).get(); RevFeatureType newFeatureType = getFeatureTypeFromId(diff.getNewFeatureType()).get(); ImmutableList<PropertyDescriptor> oldDescriptors = oldFeatureType.sortedDescriptors(); ImmutableList<PropertyDescriptor> newDescriptors = newFeatureType.sortedDescriptors(); BitSet updatedDescriptors = new BitSet(newDescriptors.size()); for (int i = 0; i < oldDescriptors.size(); i++) { PropertyDescriptor oldDescriptor = oldDescriptors.get(i); int idx = newDescriptors.indexOf(oldDescriptor); if (idx != -1) { updatedDescriptors.set(idx); } else { Class<?> oldType = oldDescriptor.getType().getBinding(); sb.append(//from www .j a v a 2s.co m "R\t" + oldDescriptors.get(i).getName().getLocalPart() + "[" + oldType.getName() + "]"); } } updatedDescriptors.flip(0, updatedDescriptors.length()); for (int i = updatedDescriptors.nextSetBit(0); i >= 0; i = updatedDescriptors.nextSetBit(i + 1)) { PropertyDescriptor newDescriptor = newDescriptors.get(i); Class<?> oldType = newDescriptor.getType().getBinding(); sb.append("A\t" + newDescriptors.get(i).getName().getLocalPart() + "[" + oldType.getName() + "]"); } } return sb.toString(); }