---
schema_version: "1"
id: 30e8c74c6457a97eb9c2e2b20dcf03a7cc37d82a5105da70e61f687dafd54198
title: Interface SalesforceFunction<T,​R>
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforce-functions/functions/guide/javasdk/interfaces/java-sf-function.md
canonical_url: https://developer.salesforce.com/docs/platform/functions/guide/java-sf-function.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: b31d236aa189f26456e1b3f1b86aaaf7a9476bae5c97c9464432c802e9c5a329
products:
  - Salesforce Functions
---
# Interface SalesforceFunction<T,​R>

Type Parameters: `T` - The type of the `InvocationEvent` payload this
function can handle. `R` - The type of the response of this function.
Functional Interface: This is a functional interface and can therefore
be used as the assignment target for a lambda expression or method
reference.

------------------------------------------------------------------------

\@FunctionalInterface public interface SalesforceFunction\<T,​R\>

Main interface for Salesforce Functions written in Java.

See Also: `BiFunction`

## Method Summary

| Modifier and Type | Method                                              | Description                                  |
| ----------------- | --------------------------------------------------- | -------------------------------------------- |
| `R`               | `apply​(InvocationEvent<T> event, Context context)` | Applies the function to the given arguments. |

## Method Details

### apply

R apply​(InvocationEvent\<T\> event, Context context) throws
java.lang.Exception

Applies the function to the given arguments.

Parameters: `event` - The invocation event for this function
application. `context` - The context for this function application.
Returns: The result of this function application. Throws:
`java.lang.Exception` - If an unrecoverable exception occurred during
function application.
