Java 类com.google.common.collect.ImmutableSortedSet.Builder 实例源码

项目:google-cloud-eclipse    文件:ArtifactRetriever.java   
@Override
public NavigableSet<ArtifactVersion> load(String coordinates) throws Exception {
  Document document = getMetadataDocument(coordinates);
  XPath xpath = XPathFactory.newInstance().newXPath();
  NodeList versionNodes = (NodeList) xpath.evaluate(
      "/metadata/versioning/versions/version",
      document,
      XPathConstants.NODESET);
  Builder<ArtifactVersion> versions = ImmutableSortedSet.naturalOrder();
  for (int i = 0; i < versionNodes.getLength(); i++) {
    String versionString = versionNodes.item(i).getTextContent();
    versions.add(new DefaultArtifactVersion(versionString));
  }
  return versions.build();
}
项目:sdh-vocabulary    文件:LanguagePack.java   
Set<String> tagUris(final String tag) {
    final Optional<Integer> langId = tagLanguage(tag);
    if(!langId.isPresent()) {
        return Collections.emptySet();
    }
    final Set<Part> tagParts = tagParts(tag);
    if(tagParts.isEmpty()) {
        throw new CorruptedLanguagePackException("Missing parts for tag '"+tag+"'");
    }
    final Builder<String> builder = ImmutableSortedSet.<String>naturalOrder();
    for(final Tag.Part part:tagParts) {
        builder.add(getProperty(languagePartUriProperty(langId.get(), part),"Coult not find uri for tag '"+tag+"' of ISO 639-"+part));
    }
    return builder.build();
}
项目:sdh-vocabulary    文件:LanguagePack.java   
Set<Tag.Part> tagParts(final String tag) {
    final String property = this.properties.getProperty(tagPartsProperty(tag));
    if(property==null) {
        return Collections.emptySet();
    }
    final Builder<Tag.Part> builder = ImmutableSortedSet.<Tag.Part>naturalOrder();
    for(final String rawPart:Splitter.on(',').splitToList(property)) {
        builder.add(part(rawPart));
    }
    return builder.build();
}
项目:sdh-vocabulary    文件:LanguagePack.java   
Set<Tag.Part> languageParts(final int langId) {
    final String property = this.properties.getProperty(languagePartsProperty(langId));
    if(property==null) {
        return Collections.emptySet();
    }
    final Builder<Tag.Part> builder = ImmutableSortedSet.<Tag.Part>naturalOrder();
    for(final String rawPart:Splitter.on(',').splitToList(property)) {
        builder.add(part(rawPart));
    }
    return builder.build();
}
项目:guava-collectors    文件:GuavaCollectors.java   
public static <T> Collector<T, ?, ImmutableList<T>> toImmutableList() {

        return Collector.of(
                ImmutableList.Builder<T>::new, 
                ImmutableList.Builder<T>::add,
                (l, r) -> l.addAll(r.build()), 
                ImmutableList.Builder<T>::build);
    }
项目:guava-collectors    文件:GuavaCollectors.java   
public static <T> Collector<T, ?, ImmutableSet<T>> toImmutableSet() {

        return Collector.of(
                ImmutableSet.Builder<T>::new, 
                ImmutableSet.Builder<T>::add,
                (l, r) -> l.addAll(r.build()), 
                ImmutableSet.Builder<T>::build);
    }
项目:guava-collectors    文件:GuavaCollectors.java   
public static <T> Collector<T, ?, ImmutableMultiset<T>> toImmutableMultiset() {

        return Collector.of(
                ImmutableMultiset.Builder<T>::new, 
                ImmutableMultiset.Builder<T>::add,
                (l, r) -> l.addAll(r.build()), 
                ImmutableMultiset.Builder<T>::build);
    }
项目:guava-collectors    文件:GuavaCollectors.java   
public static <T extends Comparable<?>> Collector<T, ImmutableSortedSet.Builder<T>, ImmutableSortedSet<T>> toImmutableSortedSet() {     

        return Collector.of(
                ImmutableSortedSet::<T> naturalOrder,
                ImmutableSortedSet.Builder<T>::add,
                (l, r) -> l.addAll(r.build()), 
                ImmutableSortedSet.Builder<T>::build );
    }
项目:guava-collectors    文件:GuavaCollectors.java   
public static <T extends Comparable<?>> Collector<T, ImmutableSortedSet.Builder<T>, ImmutableSortedSet<T>> toImmutableSortedSetReversed() {     

        return Collector.of(
                ImmutableSortedSet::<T> reverseOrder,
                ImmutableSortedSet.Builder<T>::add,
                (l, r) -> l.addAll(r.build()), 
                ImmutableSortedSet.Builder<T>::build,
                Characteristics.UNORDERED);
    }
项目:guava-collectors    文件:GuavaCollectors.java   
public static <T> Collector<T, ?, ImmutableSortedSet<T>> toImmutableSortedSet( final Supplier<Builder<T>> supplier ){

        return Collector.of(
                supplier,
                ImmutableSortedSet.Builder<T>::add,
                (l, r) -> l.addAll(r.build()), 
                ImmutableSortedSet.Builder<T>::build,
                Characteristics.UNORDERED);
    }
项目:guava-collectors    文件:GuavaCollectors.java   
public static <T> Collector<T, ?, ImmutableSortedSet<T>> toImmutableSortedSet( final Comparator<T> supplier ){;

    return Collector.of(
            () -> ImmutableSortedSet.orderedBy( supplier ),
            ImmutableSortedSet.Builder<T>::add,
            (l, r) -> l.addAll(r.build()), 
            ImmutableSortedSet.Builder<T>::build,
            Characteristics.UNORDERED); 
    }
项目:guava-collectors    文件:GuavaCollectors.java   
public static <T, K, V> Collector<T,?,ImmutableMap<K,V>> toImmutableMap(
        final Function<T,K> keyFunction,
        final Function<T,V> valueFunction ){

    return Collector.of( 
            ImmutableMap::<K,V>builder, 
            ( builder, value ) -> builder.put( keyFunction.apply( value ), valueFunction.apply( value )),
            (l, r) -> l.putAll( r.build() ),
            ImmutableMap.Builder<K,V>::build);
}
项目:guava-collectors    文件:GuavaCollectors.java   
public static <T, K, V> Collector<T,?,ImmutableBiMap<K,V>> toImmutableBiMap(
        final Function<T,K> keyFunction,
        final Function<T,V> valueFunction ){

    return Collector.of( 
            ImmutableBiMap::<K,V> builder,
            (builder, value) -> builder.put( keyFunction.apply( value ), valueFunction.apply( value )),
            (l, r) -> l.putAll( r.build() ),
            ImmutableBiMap.Builder<K,V>::build);

}
项目:guava-collectors    文件:GuavaCollectors.java   
public static <T, R, C, V> Collector<T,?,ImmutableTable<R,C,V>> toImmutableTable( 
        final Function<T,R> rowFunction,
        final Function<T,C> columnFunction,
        final Function<T,V> valueFunction ){

    return Collector.of( 
            ImmutableTable::<R,C,V> builder,
            (builder, value ) -> builder.put( rowFunction.apply( value ), columnFunction.apply( value ), valueFunction.apply( value )),
            (l, r) -> l.putAll( r.build() ),
            ImmutableTable.Builder<R,C,V>::build);      
}