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.jclouds.compute.strategy.impl.AdaptingComputeServiceStrategies.java
@Inject public AdaptingComputeServiceStrategies(Map<String, Credentials> credentialStore, PrioritizeCredentialsFromTemplate prioritizeCredentialsFromTemplate, ComputeServiceAdapter<N, H, I, L> client, Function<N, NodeMetadata> nodeMetadataAdapter, Function<I, Image> imageAdapter) { this.credentialStore = checkNotNull(credentialStore, "credentialStore"); this.prioritizeCredentialsFromTemplate = checkNotNull(prioritizeCredentialsFromTemplate, "prioritizeCredentialsFromTemplate"); this.client = checkNotNull(client, "client"); this.nodeMetadataAdapter = Functions.compose(addLoginCredentials, checkNotNull(nodeMetadataAdapter, "nodeMetadataAdapter")); this.imageAdapter = checkNotNull(imageAdapter, "imageAdapter"); }
From source file:org.opensaml.saml.common.profile.impl.PopulateSignatureSigningParameters.java
/** * Constructor.// ww w . j a v a 2s. c om */ public PopulateSignatureSigningParameters() { // Create context by default. securityParametersContextLookupStrategy = Functions.compose( new ChildContextLookup<>(SecurityParametersContext.class, true), new OutboundMessageContextLookup()); // Default: outbound msg context -> SAMLPeerEntityContext -> SAMLMetadataContext metadataContextLookupStrategy = Functions.compose(new ChildContextLookup<>(SAMLMetadataContext.class), Functions.compose(new ChildContextLookup<>(SAMLPeerEntityContext.class), new OutboundMessageContextLookup())); }
From source file:org.opensaml.saml.saml1.profile.impl.ResolveArtifacts.java
/** Constructor. */ public ResolveArtifacts() { requestLookupStrategy = Functions.compose(new MessageLookup<>(Request.class), new InboundMessageContextLookup()); responseLookupStrategy = Functions.compose(new MessageLookup<>(Response.class), new OutboundMessageContextLookup()); requesterLookupStrategy = Functions.compose(new SAMLMessageContextIssuerFunction(), new InboundMessageContextLookup()); }
From source file:org.opensaml.saml.saml2.profile.impl.CopyNameIDFromRequest.java
/** Constructor. */ public CopyNameIDFromRequest() { subjectBuilder = (SAMLObjectBuilder<Subject>) XMLObjectProviderRegistrySupport.getBuilderFactory() .<Subject>getBuilderOrThrow(Subject.DEFAULT_ELEMENT_NAME); nameIdBuilder = (SAMLObjectBuilder<NameID>) XMLObjectProviderRegistrySupport.getBuilderFactory() .<NameID>getBuilderOrThrow(NameID.DEFAULT_ELEMENT_NAME); overwriteExisting = true;/*w ww . j av a 2s. com*/ nameIdentifierContextLookupStrategy = Functions.compose( new ChildContextLookup<>(SAMLSubjectNameIdentifierContext.class, true), new InboundMessageContextLookup()); responseLookupStrategy = Functions.compose(new MessageLookup<>(Response.class), new OutboundMessageContextLookup()); }
From source file:org.apache.brooklyn.core.sensor.ssh.SshCommandSensor.java
@Override public void apply(final EntityLocal entity) { super.apply(entity); if (LOG.isDebugEnabled()) { LOG.debug("Adding SSH sensor {} to {}", name, entity); }/*www.j a va2 s .c om*/ Supplier<Map<String, String>> envSupplier = new Supplier<Map<String, String>>() { @Override public Map<String, String> get() { return MutableMap .copyOf(Strings.toStringMap(entity.getConfig(BrooklynConfigKeys.SHELL_ENVIRONMENT), "")); } }; Supplier<String> commandSupplier = new Supplier<String>() { @Override public String get() { return makeCommandExecutingInDirectory(command, executionDir, entity); } }; SshPollConfig<T> pollConfig = new SshPollConfig<T>(sensor).period(period).env(envSupplier) .command(commandSupplier).checkSuccess(SshValueFunctions.exitStatusEquals(0)) .onFailureOrException(Functions.constant((T) null)) .onSuccess(Functions.compose(new Function<String, T>() { @Override public T apply(String input) { return TypeCoercions.coerce(input, getType(type)); } }, SshValueFunctions.stdout())); SshFeed.builder().entity(entity).onlyIfServiceUp().poll(pollConfig).build(); }
From source file:org.opensaml.saml.saml2.profile.impl.EncryptNameIDs.java
/** Constructor. */ public EncryptNameIDs() { messageLookupStrategy = Functions.compose(new MessageLookup<>(SAMLObject.class), new OutboundMessageContextLookup()); excludedFormats = Collections.singleton(NameID.ENTITY); }
From source file:com.facebook.buck.features.lua.LuaStandaloneBinary.java
@Override public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) { ImmutableList.Builder<Step> steps = ImmutableList.builder(); buildableContext.recordArtifact(output); // Make sure the parent directory exists. steps.add(MkdirStep.of(BuildCellRelativePath.fromCellRelativePath(context.getBuildCellRootPath(), getProjectFilesystem(), output.getParent()))); // Delete any other pex that was there (when switching between pex styles). steps.add(RmStep.of(BuildCellRelativePath.fromCellRelativePath(context.getBuildCellRootPath(), getProjectFilesystem(), output)).withRecursive(true)); SourcePathResolver resolver = context.getSourcePathResolver(); steps.add(new ShellStep(getProjectFilesystem().getRootPath()) { @Override/*from w w w . j a v a 2 s. c om*/ protected Optional<String> getStdin(ExecutionContext context) { try { return Optional.of(ObjectMappers.WRITER.writeValueAsString(ImmutableMap.of("modules", Maps.transformValues(components.getModules(), Functions.compose(Object::toString, resolver::getAbsolutePath)), "pythonModules", Maps.transformValues(components.getPythonModules(), Functions.compose(Object::toString, resolver::getAbsolutePath)), "nativeLibraries", Maps.transformValues(components.getNativeLibraries(), Functions.compose(Object::toString, resolver::getAbsolutePath))))); } catch (IOException e) { throw new RuntimeException(e); } } @Override protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) { ImmutableList.Builder<String> command = ImmutableList.builder(); command.addAll(builder.getCommandPrefix(resolver)); command.addAll(builderArgs); command.add("--entry-point", mainModule); command.add("--interpreter"); if (starter.isPresent()) { command.add(resolver.getAbsolutePath(starter.get()).toString()); } else { command.add(lua.getCommandPrefix(resolver).get(0)); } command.add(getProjectFilesystem().resolve(output).toString()); return command.build(); } @Override public String getShortName() { return "lua_package"; } }); return steps.build(); }
From source file:net.shibboleth.idp.saml.profile.impl.BaseAddAttributeStatementToAssertion.java
/** Constructor. */ public BaseAddAttributeStatementToAssertion() { statementInOwnAssertion = false;/* w ww . j a v a 2 s . c om*/ ignoringUnencodableAttributes = true; attributeContextLookupStrategy = Functions.compose(new ChildContextLookup<>(AttributeContext.class), new ChildContextLookup<ProfileRequestContext, RelyingPartyContext>(RelyingPartyContext.class)); idGeneratorLookupStrategy = new IdentifierGenerationStrategyLookupFunction(); issuerLookupStrategy = new ResponderIdLookupFunction(); }
From source file:fi.okm.mpass.shibboleth.authn.impl.InitializeShibbolethSpAuthenticationContext.java
/** Constructor. */ public InitializeShibbolethSpAuthenticationContext() { authnRequestLookupStrategy = Functions.compose(new MessageLookup<>(AuthnRequest.class), new InboundMessageContextLookup()); relyingPartyContextLookupStrategy = new ChildContextLookup<>(RelyingPartyContext.class); }
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, K3, V3> reducer) { return Functions.compose(asFunction(reducer), asFunction(mapper)); }