List of usage examples for com.google.common.base Functions compose
public static <A, B, C> Function<A, C> compose(Function<B, C> g, Function<A, ? extends B> f)
From source file:org.opensaml.saml.saml1.profile.impl.AddStatusToResponse.java
/** Constructor. */ public AddStatusToResponse() { responseLookupStrategy = Functions.compose(new MessageLookup<>(Response.class), new OutboundMessageContextLookup()); detailedErrorsCondition = Predicates.alwaysFalse(); defaultStatusCodes = Collections.emptyList(); detailedErrors = false;//from w w w . ja va 2s.c om }
From source file:org.opensaml.saml.saml2.profile.impl.AddStatusToResponse.java
/** Constructor. */ public AddStatusToResponse() { responseLookupStrategy = Functions.compose(new MessageLookup<>(StatusResponseType.class), new OutboundMessageContextLookup()); detailedErrorsCondition = Predicates.alwaysFalse(); defaultStatusCodes = Collections.emptyList(); detailedErrors = false;// w w w.ja v a 2s. co m }
From source file:net.shibboleth.idp.ui.impl.SetRPUIInformation.java
/** Constructor. */ public SetRPUIInformation() { metadataContextLookupStrategy = Functions.compose(new ChildContextLookup<>(SAMLMetadataContext.class), Functions.compose(new ChildContextLookup<>(SAMLPeerEntityContext.class), new OutboundMessageContextLookup())); rpUIContextCreateStrategy = Functions.compose(new ChildContextLookup<>(RelyingPartyUIContext.class, true), new ChildContextLookup<ProfileRequestContext, AuthenticationContext>(AuthenticationContext.class, true));/*from w w w. j av a 2 s. com*/ }
From source file:org.opensaml.saml.saml1.profile.impl.CopyNameIdentifierFromRequest.java
/** Constructor. */ public CopyNameIdentifierFromRequest() { subjectBuilder = (SAMLObjectBuilder<Subject>) XMLObjectProviderRegistrySupport.getBuilderFactory() .<Subject>getBuilderOrThrow(Subject.DEFAULT_ELEMENT_NAME); nameIdentifierBuilder = (SAMLObjectBuilder<NameIdentifier>) XMLObjectProviderRegistrySupport .getBuilderFactory().<NameIdentifier>getBuilderOrThrow(NameIdentifier.DEFAULT_ELEMENT_NAME); overwriteExisting = true;/*from www. j a v a2 s . co m*/ nameIdentifierContextLookupStrategy = Functions.compose( new ChildContextLookup<>(SAMLSubjectNameIdentifierContext.class, true), new InboundMessageContextLookup()); responseLookupStrategy = Functions.compose(new MessageLookup<>(Response.class), new OutboundMessageContextLookup()); }
From source file:org.apache.abdera2.common.misc.MapRed.java
public static <K1, V1, K2, V2, K3, V3> Function<Iterable<Pair<K1, V1>>, Iterable<Pair<K3, Iterable<V3>>>> compose( Mapper<K1, V1, K2, V2> mapper, Reducer<K2, V2, K2, V2> combiner, Reducer<K2, V2, K3, V3> reducer) { return Functions.compose(asFunction(reducer), Functions.compose(asFunction(combiner), asFunction(mapper))); }
From source file:com.google.enterprise.connector.ldap.LdapJsonDocumentFetcher.java
@Override public Iterator<JsonDocument> iterator() { Map<String, Multimap<String, String>> results; try {//from ww w.j a v a 2 s . co m results = mapOfMultimapsSupplier.get(); // reset wait counter waitcounter = 0; } catch (IllegalStateException e) { LOG.log(Level.SEVERE, "Encountered IllegalStateException, will wait and continue.", e); try { // wait for some time to check if the unavailable ldap source would be // back long sleepTime; if (waitcounter < waitTimes.length) { sleepTime = waitTimes[waitcounter]; } else { sleepTime = waitTimes[waitTimes.length - 1]; } LOG.info("Waiting for " + sleepTime + " milliseconds."); Thread.sleep(sleepTime); waitcounter++; } catch (InterruptedException e1) { LOG.fine("Interrupted while waiting after IllegalStateException."); } // The full stack trace was logged above, before the wait period, // so pass a null cause rather than e. throw new SnapshotRepositoryRuntimeException(e.getMessage(), null); } return Iterators.transform(results.entrySet().iterator(), Functions.compose(JsonDocument.buildFromMultimap, addDocid)); }
From source file:com.metamx.druid.query.group.GroupByQuery.java
@JsonCreator public GroupByQuery(@JsonProperty("dataSource") String dataSource, @JsonProperty("intervals") QuerySegmentSpec querySegmentSpec, @JsonProperty("filter") DimFilter dimFilter, @JsonProperty("granularity") QueryGranularity granularity, @JsonProperty("dimensions") List<DimensionSpec> dimensions, @JsonProperty("aggregations") List<AggregatorFactory> aggregatorSpecs, @JsonProperty("postAggregations") List<PostAggregator> postAggregatorSpecs, @JsonProperty("having") HavingSpec havingSpec, @JsonProperty("limitSpec") LimitSpec limitSpec, @JsonProperty("orderBy") LimitSpec orderBySpec, @JsonProperty("context") Map<String, String> context) { super(dataSource, querySegmentSpec, context); this.dimFilter = dimFilter; this.granularity = granularity; this.dimensions = dimensions == null ? ImmutableList.<DimensionSpec>of() : dimensions; this.aggregatorSpecs = aggregatorSpecs; this.postAggregatorSpecs = postAggregatorSpecs == null ? ImmutableList.<PostAggregator>of() : postAggregatorSpecs;/*from w w w .j a va 2s. c o m*/ this.havingSpec = havingSpec; this.limitSpec = (limitSpec == null) ? (orderBySpec == null ? new NoopLimitSpec() : orderBySpec) : limitSpec; Preconditions.checkNotNull(this.granularity, "Must specify a granularity"); Preconditions.checkNotNull(this.aggregatorSpecs, "Must specify at least one aggregator"); Queries.verifyAggregations(this.aggregatorSpecs, this.postAggregatorSpecs); Function<Sequence<Row>, Sequence<Row>> postProcFn = this.limitSpec.build(this.dimensions, this.aggregatorSpecs, this.postAggregatorSpecs); if (havingSpec != null) { postProcFn = Functions.compose(new Function<Sequence<Row>, Sequence<Row>>() { @Override public Sequence<Row> apply(@Nullable Sequence<Row> input) { return Sequences.filter(input, new Predicate<Row>() { @Override public boolean apply(@Nullable Row input) { return GroupByQuery.this.havingSpec.eval(input); } }); } }, postProcFn); } orderByLimitFn = postProcFn; }
From source file:net.shibboleth.idp.saml.relyingparty.impl.RelyingPartyConfigurationSupport.java
/** * A shorthand method for constructing a {@link RelyingPartyConfiguration} with an activation condition based on * an {@link EntityAttributesPredicate}. * //from w w w. j av a2 s .c om * @param candidates the candidate rules * @param trim true iff tag values in metadata should be trimmed before comparison * @param matchAll true iff all the candidate rules are required to match * * @return a default-constructed configuration with the appropriate condition set */ @Nonnull public static RelyingPartyConfiguration byTag(@Nonnull @NonnullElements final Collection<Candidate> candidates, final boolean trim, final boolean matchAll) { Constraint.isNotNull(candidates, "Candidate list cannot be null"); // We adapt an OpenSAML Predicate applying to an EntityDescriptor by indirecting the lookup of the // EntityDescriptor to a lookup sequence of PRC -> RPC -> SAMLMetadataContext -> EntityDescriptor. final StrategyIndirectedPredicate<ProfileRequestContext, EntityDescriptor> indirectPredicate = new StrategyIndirectedPredicate<>( Functions.compose(new EntityDescriptorLookupFunction(), new SAMLMetadataContextLookupFunction()), new EntityAttributesPredicate(candidates, trim, matchAll)); final RelyingPartyConfiguration config = new RelyingPartyConfiguration(); config.setActivationCondition(indirectPredicate); return config; }
From source file:io.druid.query.groupby.GroupByQuery.java
@JsonCreator public GroupByQuery(@JsonProperty("dataSource") DataSource dataSource, @JsonProperty("intervals") QuerySegmentSpec querySegmentSpec, @JsonProperty("filter") DimFilter dimFilter, @JsonProperty("granularity") QueryGranularity granularity, @JsonProperty("dimensions") List<DimensionSpec> dimensions, @JsonProperty("aggregations") List<AggregatorFactory> aggregatorSpecs, @JsonProperty("postAggregations") List<PostAggregator> postAggregatorSpecs, @JsonProperty("having") HavingSpec havingSpec, @JsonProperty("limitSpec") LimitSpec limitSpec, @JsonProperty("context") Map<String, Object> context) { super(dataSource, querySegmentSpec, context); this.dimFilter = dimFilter; this.granularity = granularity; this.dimensions = dimensions == null ? ImmutableList.<DimensionSpec>of() : dimensions; for (DimensionSpec spec : this.dimensions) { Preconditions.checkArgument(spec != null, "dimensions has null DimensionSpec"); }/*w w w .j a v a 2 s . c om*/ this.aggregatorSpecs = aggregatorSpecs; this.postAggregatorSpecs = postAggregatorSpecs == null ? ImmutableList.<PostAggregator>of() : postAggregatorSpecs; this.havingSpec = havingSpec; this.limitSpec = (limitSpec == null) ? new NoopLimitSpec() : limitSpec; Preconditions.checkNotNull(this.granularity, "Must specify a granularity"); Preconditions.checkNotNull(this.aggregatorSpecs, "Must specify at least one aggregator"); Queries.verifyAggregations(this.aggregatorSpecs, this.postAggregatorSpecs); Function<Sequence<Row>, Sequence<Row>> postProcFn = this.limitSpec.build(this.dimensions, this.aggregatorSpecs, this.postAggregatorSpecs); if (havingSpec != null) { postProcFn = Functions.compose(postProcFn, new Function<Sequence<Row>, Sequence<Row>>() { @Override public Sequence<Row> apply(Sequence<Row> input) { return Sequences.filter(input, new Predicate<Row>() { @Override public boolean apply(Row input) { return GroupByQuery.this.havingSpec.eval(input); } }); } }); } limitFn = postProcFn; }
From source file:com.eucalyptus.ws.util.ErrorHandlerSupport.java
protected static Optional<Integer> getHttpResponseStatus(final Throwable t) { final QueryBindingInfo info = Ats.inClassHierarchy(t.getClass()).get(QueryBindingInfo.class); final Optional<Integer> status = info == null ? Optional.<Integer>absent() : Optional.of(info.statusCode()); return Iterables.tryFind(Exceptions.causes(t), Predicates.instanceOf(HasHttpStatusCode.class)) .transform(Functions.compose(HasHttpStatusCode.Utils.httpStatusCode(), CollectionUtils.cast(HasHttpStatusCode.class))) .or(status);//from w w w .j av a 2 s . c om }