List of usage examples for com.google.common.collect Sets newTreeSet
public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator)
From source file:com.github.fge.jsonschema.keyword.digest.draftv3.DraftV3DependenciesDigester.java
private static JsonNode sortedSet(final JsonNode node) { final SortedSet<JsonNode> set = Sets.newTreeSet(new Comparator<JsonNode>() { @Override//from w w w . j av a 2s . c o m public int compare(final JsonNode o1, final JsonNode o2) { return o1.textValue().compareTo(o2.textValue()); } }); set.addAll(Sets.newHashSet(node)); final ArrayNode ret = FACTORY.arrayNode(); ret.addAll(set); return ret; }
From source file:kr.co.vcnc.haeinsa.HaeinsaDelete.java
/** * Delete all versions of all columns of the specified family. * <p>/*from w w w . j a v a2 s . c o m*/ * Overrides previous calls to deleteColumn and deleteColumns for the * specified family. * * @param family family name * @return this for invocation chaining */ public HaeinsaDelete deleteFamily(byte[] family) { NavigableSet<HaeinsaKeyValue> set = familyMap.get(family); if (set == null) { set = Sets.newTreeSet(HaeinsaKeyValue.COMPARATOR); } else if (!set.isEmpty()) { set.clear(); } set.add(new HaeinsaKeyValue(row, family, null, null, KeyValue.Type.DeleteFamily)); familyMap.put(family, set); return this; }
From source file:uk.ac.ebi.atlas.model.Experiment.java
public Experiment(ExperimentType type, String accession, Date lastUpdate, String displayName, String description, boolean hasExtraInfoFile, Set<String> organisms, String kingdom, Map<String, String> speciesMapping, Set<String> pubMedIds, ExperimentDesign experimentDesign) { this.type = type; this.lastUpdate = lastUpdate; this.experimentDesign = experimentDesign; this.accession = accession; this.displayName = displayName; this.description = description; this.hasExtraInfoFile = hasExtraInfoFile; this.organisms = new TreeSet<>(organisms); this.kingdom = kingdom; this.speciesMapping = speciesMapping; this.pubMedIds = Sets.newTreeSet(pubMedIds); }
From source file:com.gravitant.cloud.adapters.provision.providers.VolumeDetached.java
public boolean apply(Attachment attachment) { logger.trace("looking for volume %s", attachment.getVolumeId()); Volume volume = Iterables/* w w w. j a v a 2 s. co m*/ .getOnlyElement(client.describeVolumesInRegion(attachment.getRegion(), attachment.getVolumeId())); /*If attachment size is 0 volume is detached for sure.*/ if (volume.getAttachments().size() == 0) { return true; } /* But if attachment size is > 0, then the attachment could be in any state. * So we need to check if the status is DETACHED (return true) or not (return false). */ Attachment lastAttachment = Sets.newTreeSet(volume.getAttachments()).last(); logger.trace("%s: looking for status %s: currently: %s", lastAttachment, Attachment.Status.DETACHED, lastAttachment.getStatus()); return lastAttachment.getStatus() == Attachment.Status.DETACHED; }
From source file:org.apache.brooklyn.rest.transform.CatalogTransformer.java
public static <T extends Entity> CatalogEntitySummary catalogEntitySummary(BrooklynRestResourceUtils b, CatalogItem<T, EntitySpec<? extends T>> item) { Set<EntityConfigSummary> config = Sets.newLinkedHashSet(); Set<SensorSummary> sensors = Sets.newTreeSet(SummaryComparators.nameComparator()); Set<EffectorSummary> effectors = Sets.newTreeSet(SummaryComparators.nameComparator()); EntitySpec<?> spec = null;//from ww w . j a v a 2 s . co m try { @SuppressWarnings({ "unchecked", "rawtypes" }) // the raw type isn't needed according to eclipse IDE, but jenkins maven fails without it; // must be a java version or compiler thing. don't remove even though it looks okay without it! EntitySpec<?> specRaw = (EntitySpec<?>) b.getCatalog().createSpec((CatalogItem) item); spec = specRaw; EntityDynamicType typeMap = BrooklynTypes.getDefinedEntityType(spec.getType()); EntityType type = typeMap.getSnapshot(); AtomicInteger paramPriorityCnt = new AtomicInteger(); for (SpecParameter<?> input : spec.getParameters()) { config.add(EntityTransformer.entityConfigSummary(input, paramPriorityCnt)); if (input.getSensor() != null) sensors.add(SensorTransformer.sensorSummaryForCatalog(input.getSensor())); } for (Sensor<?> x : type.getSensors()) sensors.add(SensorTransformer.sensorSummaryForCatalog(x)); for (Effector<?> x : type.getEffectors()) effectors.add(EffectorTransformer.effectorSummaryForCatalog(x)); } catch (Exception e) { Exceptions.propagateIfFatal(e); // templates with multiple entities can't have spec created in the manner above; just ignore if (item.getCatalogItemType() == CatalogItemType.ENTITY) { log.warn("Unable to create spec for " + item + ": " + e, e); } if (log.isTraceEnabled()) { log.trace("Unable to create spec for " + item + ": " + e, e); } } return new CatalogEntitySummary(item.getSymbolicName(), item.getVersion(), item.getDisplayName(), item.getJavaType(), item.getPlanYaml(), item.getDescription(), tidyIconLink(b, item, item.getIconUrl()), makeTags(spec, item), config, sensors, effectors, item.isDeprecated(), makeLinks(item)); }
From source file:com.google.javascript.jscomp.RecordFunctionInformation.java
@Override public void process(Node externs, Node root) { NodeTraversal.traverse(compiler, root, this); if (moduleGraph == null) { addModuleInformation(null);//from www. jav a 2 s . c o m } else { // The test expects a consistent module order. TreeSet<JSModule> modules = Sets.newTreeSet(new Comparator<JSModule>() { public int compare(JSModule o1, JSModule o2) { return o1.getName().compareTo(o2.getName()); } }); Iterables.addAll(modules, moduleGraph.getAllModules()); for (JSModule m : modules) { addModuleInformation(m); } } }
From source file:org.opentestsystem.delivery.testreg.upload.validator.fileformat.DuplicateRecordProcessor.java
private SortedSet<DataRecord> sort(final Set<DataRecord> recordSet) { final SortedSet<DataRecord> sortedSet = Sets.newTreeSet(new RowIndexBasedComparator()); sortedSet.addAll(recordSet);/*from w w w. ja v a2 s .c o m*/ return sortedSet; }
From source file:org.opentestsystem.shared.security.domain.SbacRole.java
public static Collection<GrantedAuthority> calculateGrantedAuthority(final Collection<SbacRole> inSbacRoles) { final Set<GrantedAuthority> ret = Sets.newTreeSet(new SbacPermission.GrantedAuthorityComparator()); if (inSbacRoles != null && !inSbacRoles.isEmpty()) { for (final SbacRole role : inSbacRoles) { if (role.getPermissions() != null) { ret.addAll(role.getPermissions()); }/*from w w w . j a v a2 s . com*/ } } return ret; }
From source file:com.textocat.textokit.commons.util.ConfigPropertiesUtils.java
public static String prettyString(Properties props) { StringBuilder sb = new StringBuilder(); for (String key : Sets.newTreeSet(props.stringPropertyNames())) { sb.append(key).append("="); sb.append(props.getProperty(key)); sb.append("\n"); }// w ww . ja v a 2s .c o m return sb.toString(); }
From source file:org.incode.module.commchannel.dom.impl.channel.CommunicationChannelRepository.java
@Programmatic public SortedSet<CommunicationChannel> findByOwnerAndType(final Object owner, final CommunicationChannelType type) { final List<CommunicationChannelOwnerLink> links = linkRepository .findByOwnerAndCommunicationChannelType(owner, type); return Sets.newTreeSet( Iterables.transform(links, CommunicationChannelOwnerLink.Functions.communicationChannel())); }