Java Code Examples for com.google.common.base.Suppliers#compose()

The following examples show how to use com.google.common.base.Suppliers#compose() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrooklynTaskTags.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
/** creates a tag suitable for marking a stream available on a task, but which might be GC'd */
// TODO only make it soft if/when stream exceeds a given size eg 1kb ?
public static WrappedStream tagForStreamSoft(String streamType, ByteArrayOutputStream stream) {
    MemoryUsageTracker.SOFT_REFERENCES.track(stream, stream.size());
    Maybe<ByteArrayOutputStream> softStream = Maybe.softThen(stream, STREAM_GARBAGE_COLLECTED_MAYBE);
    return new WrappedStream(streamType,
        Suppliers.compose(Functions.toStringFunction(), softStream),
        Suppliers.compose(Streams.sizeFunction(), softStream));
}
 
Example 2
Source File: AttributeAggregate.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
static AttributeAggregate create(Supplier<Iterable<IAttribute>> attributes) {
  Supplier<Multiset<Pair<String, String>>> aggregator = Suppliers.compose(
      attributes1 -> addAttributes(ImmutableMultiset.builder(), attributes1).build(),
      attributes);

  return new AttributeAggregate(aggregator);
}
 
Example 3
Source File: Strings.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
public static Supplier<String> toStringSupplier(Object src) {
    return Suppliers.compose(Functions.toStringFunction(), Suppliers.ofInstance(src));
}