Example usage for com.google.common.base Functions compose

List of usage examples for com.google.common.base Functions compose

Introduction

In this page you can find the example usage for com.google.common.base Functions compose.

Prototype

public static <A, B, C> Function<A, C> compose(Function<B, C> g, Function<A, ? extends B> f) 

Source Link

Document

Returns the composition of two functions.

Usage

From source file:net.shibboleth.idp.saml.profile.config.logic.IncludeAttributeStatementPredicate.java

/** Constructor. */
public IncludeAttributeStatementPredicate() {
    bindingContextLookupStrategy = Functions.compose(new ChildContextLookup<>(SAMLBindingContext.class),
            new OutboundMessageContextLookup());
}

From source file:dagger.internal.codegen.SimpleAnnotationMirror.java

private SimpleAnnotationMirror(TypeElement annotationType, Map<String, ? extends AnnotationValue> namedValues) {
    checkArgument(annotationType.getKind().equals(ElementKind.ANNOTATION_TYPE),
            "annotationType must be an annotation: %s", annotationType);
    checkArgument(FluentIterable.from(methodsIn(annotationType.getEnclosedElements()))
            .transform(element -> element.getSimpleName().toString()).toSet().equals(namedValues.keySet()),
            "namedValues must have values for exactly the members in %s: %s", annotationType, namedValues);
    this.annotationType = annotationType;
    this.namedValues = ImmutableMap.copyOf(namedValues);
    this.elementValues = Maps.toMap(methodsIn(annotationType.getEnclosedElements()),
            Functions.compose(Functions.forMap(namedValues), element -> element.getSimpleName().toString()));
}

From source file:edu.harvard.med.screensaver.service.screens.ScreenDerivedPropertiesUpdater.java

@Transactional
public Screen updateScreeningStatistics(Screen screenIn) {
    _dao.flush(); // ensure all of the data that were are about to query is flushed to the database
    Screen screen = (Screen) _dao.reloadEntity(screenIn);
    SortedSet<AssayPlate> assayPlatesScreened = screen.getAssayPlatesScreened();
    SortedSet<AssayPlate> assayPlatesDataLoaded = screen.getAssayPlatesDataLoaded();

    Set<Integer> plateNumbersScreened = Sets
            .newHashSet(Iterables.transform(assayPlatesScreened, AssayPlate.ToPlateNumber));
    Set<Integer> plateNumbersLoaded = Sets
            .newHashSet(Iterables.transform(assayPlatesDataLoaded, AssayPlate.ToPlateNumber));

    Function<AssayPlate, Library> AssayPlateToLibrary = Functions.compose(Copy.ToLibrary,
            Functions.compose(Plate.ToCopy, AssayPlate.ToPlate));
    Set<Library> librariesScreened = Sets
            .newHashSet(Iterables.transform(assayPlatesScreened, AssayPlateToLibrary));

    screen.setAssayPlatesScreenedCount(assayPlatesScreened.size());
    screen.setLibraryPlatesScreenedCount(plateNumbersScreened.size());
    screen.setLibraryPlatesDataLoadedCount(plateNumbersLoaded.size());
    // TODO: currently, all loaded data is also already analyzed; this will change in the future; see [#1315]
    screen.setLibraryPlatesDataAnalyzedCount(plateNumbersLoaded.size());
    screen.setLibrariesScreenedCount(librariesScreened.size());

    SortedSet<Integer> maxReplicatesPerPlateNumber = findMaxReplicatesPerPlateNumber(assayPlatesScreened);
    screen.setMinScreenedReplicateCount(
            maxReplicatesPerPlateNumber.isEmpty() ? null : maxReplicatesPerPlateNumber.first());
    screen.setMaxScreenedReplicateCount(
            maxReplicatesPerPlateNumber.isEmpty() ? null : maxReplicatesPerPlateNumber.last());

    maxReplicatesPerPlateNumber = findMaxReplicatesPerPlateNumber(assayPlatesDataLoaded);
    screen.setMinDataLoadedReplicateCount(
            maxReplicatesPerPlateNumber.isEmpty() ? null : maxReplicatesPerPlateNumber.first());
    screen.setMaxDataLoadedReplicateCount(
            maxReplicatesPerPlateNumber.isEmpty() ? null : maxReplicatesPerPlateNumber.last());

    screen.setScreenedExperimentalWellCount(_screenDao.countScreenedExperimentalWells(screen, false));
    screen.setUniqueScreenedExperimentalWellCount(_screenDao.countScreenedExperimentalWells(screen, true));

    if (screen.getScreenResult() != null) {
        screen.getScreenResult().setExperimentalWellCount(_screenDao.countLoadedExperimentalWells(screen));
    }//from   w  w w . j  av  a  2  s  . c o  m
    return screen;
}

From source file:net.shibboleth.idp.attribute.filter.policyrule.filtercontext.impl.PredicatePolicyRule.java

/** Constructor. */
public PredicatePolicyRule() {
    profileContextStrategy = Functions.compose(
            new ParentContextLookup<RelyingPartyContext, ProfileRequestContext>(),
            new ParentContextLookup<AttributeFilterContext, RelyingPartyContext>());
}

From source file:org.nickelproject.nickel.dataflow.Collector.java

public static <I, K, T, V> Collector<I, Source<Pair<K, V>>> groupBy(final Function<I, K> keyFunction,
        final Collector<I, V> aggregator) {
    final Reducer<Map<K, T>> mapReducer = MapMergingReducer
            .create((Reducer<T>) aggregator.collectorBase.reducer);
    final Function<I, Pair<I, I>> toPairFunction = new ToPairFunction<I>();
    final Function<Pair<I, I>, Pair<K, T>> pairFunction = PairFunction.of(keyFunction,
            (Function<I, T>) aggregator.collectorBase.preFunctor);
    final Function<Pair<K, T>, Map<K, T>> toMap = new ToMapFunction();
    return Collector.create(Functions.compose(toMap, Functions.compose(pairFunction, toPairFunction)),
            mapReducer,//from   w  w  w  . jav a2  s .  c  o  m
            Functions.compose(
                    new TransformSourceFunction(PairFunction.of(Functions.<K>identity(),
                            (Function<T, V>) aggregator.collectorBase.postFunctor)),
                    new MapToPairSourceFunction<K, T>()));
}

From source file:org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConfiguration.java

void setProducts(Map<String, Product> products) {
    Function<Product, String> getName = new Function<Product, String>() {
        public String apply(Product item) {
            return item.getName();
        }/*w ww . j  a v  a2  s. c o  m*/
    };
    Function<String, String> comparatorFunction = Functions.compose(getName, Functions.forMap(products));
    Ordering<String> comparator = Ordering.natural().onResultOf(comparatorFunction);
    this.products = ImmutableSortedMap.copyOf(products, comparator);
}

From source file:edu.harvard.med.screensaver.service.libraries.LibraryScreeningDerivedPropertiesUpdater.java

@Transactional
public void updateScreeningStatistics(LibraryScreening libraryScreeningIn) {
    _dao.flush(); // ensure that new library screenings are flushed
    LibraryScreening libraryScreening = _dao.reloadEntity(libraryScreeningIn);
    int n = 0;//  w ww  .ja v a 2s . com

    Set<Integer> plateNumbersScreened = Sets.newHashSet(
            Iterables.transform(libraryScreening.getAssayPlatesScreened(), AssayPlate.ToPlateNumber));
    for (Integer plateNumber : plateNumbersScreened) {
        n += _librariesDao.countExperimentalWells(plateNumber, plateNumber);
    }
    libraryScreening.setScreenedExperimentalWellCount(n);

    Function<AssayPlate, Library> AssayPlateToLibrary = Functions.compose(Copy.ToLibrary,
            Functions.compose(Plate.ToCopy, AssayPlate.ToPlate));
    Set<Library> librariesScreened = Sets
            .newHashSet(Iterables.transform(libraryScreening.getAssayPlatesScreened(), AssayPlateToLibrary));
    libraryScreening.setLibrariesScreenedCount(librariesScreened.size());
    libraryScreening.setLibraryPlatesScreenedCount(plateNumbersScreened.size());

    _screenDerivedPropertiesUpdater.updateScreeningStatistics(libraryScreening.getScreen());
}

From source file:org.opensaml.saml.common.profile.impl.AddNotBeforeConditionToAssertions.java

/** Constructor. */
public AddNotBeforeConditionToAssertions() {
    responseLookupStrategy = Functions.compose(new MessageLookup<>(SAMLObject.class),
            new OutboundMessageContextLookup());
}

From source file:org.lmnl.util.OverlapIndexer.java

public SortedMap<Range, List<Annotation>> apply(Iterable<Annotation> from) {
    return Functions.compose(new Indexer(from), new Partitioning(partitioningFilter)).apply(from);
}

From source file:brooklyn.entity.waratek.cloudvm.WaratekAttributes.java

/** Setup renderer hints for the MXBean attributes. */
@SuppressWarnings("rawtypes")
public static void init() {
    if (initialized.getAndSet(true))
        return;/*  w  ww .  j  av a2 s.c  o m*/

    Function longValue = new Function<Double, Long>() {
        @Override
        public Long apply(@Nullable Double input) {
            if (input == null)
                return null;
            return input.longValue();
        }

    };

    RendererHints.register(TOTAL_HEAP_MEMORY, RendererHints.displayValue(ByteSizeStrings.metric()));
    RendererHints.register(HEAP_MEMORY_DELTA_PER_SECOND_LAST,
            RendererHints.displayValue(Functions.compose(ByteSizeStrings.metric(), longValue)));
    RendererHints.register(HEAP_MEMORY_DELTA_PER_SECOND_IN_WINDOW,
            RendererHints.displayValue(Functions.compose(ByteSizeStrings.metric(), longValue)));

    RendererHints.register(BYTES_SENT, RendererHints.displayValue(ByteSizeStrings.iso()));
    RendererHints.register(BYTES_RECEIVED, RendererHints.displayValue(ByteSizeStrings.iso()));
}