Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

Questions tagged [interface]

An interface is like a class, but it only contains the method's signatures. Interfaces can provide a layer of abstraction to code, and is an element of object-oriented programming.

Filter by
Sorted by
Tagged with
6 votes
1 answer
82 views

Covariant Return Types in Interfaces

Having recently rolled out a beta version of my open source project, I started looking for ways to optimize it, and accidentally came across the fact that apex actually supports covariant return types ...
user avatar
-3 votes
1 answer
37 views

Whats best suited in the below scenario (Interface ? Abstract ? Inheritance)

I have two classes. They both contain a method that has almost the same logic. But the methods differ in a number of parameters. I want to keep a common method in the base class and use it in several ...
user avatar
6 votes
1 answer
166 views

Invoking Interface Method in Abstract Class Method

Assume we have some interface, abstract class and contrete class: interface I { void foo(); void bar(); } abstract class A implements I { public void barFoo() { bar(); // Compile ...
user avatar
13 votes
1 answer
461 views

Interface method can be implemented as static

Assume we have some simple interface: public interface IExecutable { void execute(); } and some class that implements the interface: public class Executor implements IExecutable { public ...
user avatar
6 votes
1 answer
357 views

How to implement Lambda expression in Apex

I have this below interface in Java public interface DoubleOperator { double applyAsDouble(double left, double right); } And below implementing it using Lambda - DoubleOperator [] ops = { (a, b)...
user avatar
  • 1,516
0 votes
1 answer
116 views

How to define a interface datatype? [duplicate]

I was preparing for PD1 exam and came across the below sentence on interface in the developer documentation which I’m unable to understand. Can anyone help with an example as to what the below ...
user avatar
1 vote
1 answer
75 views

How to call an Apex Class and method using Type casting?

I would like to call someMethod1 and someMethod2 from myClass from a Trigger on update. How can I use type casting to call the two methods? myInterfaceClass public interface myInterfaceClass { void ...
user avatar
2 votes
1 answer
67 views

Can managed Apex code instantiate a type that is outside its namespace?

In a managed package I have a global interface and some code that accepts a string as input (which should be a class name). Will this managed code be able to instantiate an Apex type that is outside ...
user avatar
2 votes
1 answer
193 views

Packaged Interface cannot be instantiated after critical update "Restrict Reflective Access to Non-Global Constructors in Packages"

We have a global apex interface in a managed package that enables a subscriber org to transform a field value during a calculation in our package. global interface CustomCallable { Object execute(...
user avatar
0 votes
1 answer
64 views

Design Pattern Help: Extended Interfaces with methods that shared the same functionality/code

I'm trying to figure out the best pattern for the code below (example: not actual code). IOpportunitiesA and IOpportunitiesB are extending the base interface and they have a similar method, ...
user avatar
  • 765
1 vote
0 answers
25 views

Class vs Interface in Patch org

Why am I able to change the access specifier for an interface in a patch org but I can't do the same for a class? I know the documentation mentions some restrictions for patch orgs. I'm assuming the ...
user avatar
  • 1,313
5 votes
2 answers
395 views

An inner interface inside an outer interface is not supported in Apex?

Can't find a post saying this, and I get a compile error, but just to be sure, this is not supported in Apex right? public interface Access { public interface Context { ... } ...
user avatar
  • 129k
2 votes
1 answer
166 views

Do callable classes still need to be marked as global to access them outside of managed packages?

I created a callable class for a managed packaged but I am unable to actually get an instance while calling it from outside the package. In execute anonymous: Type.forName returns null Callable ...
user avatar
  • 2,584
1 vote
1 answer
216 views

Object Permissions from permissions sets don't work as expected

What does the " -- " in the type of permission object? I need to set this to readOnly
user avatar
2 votes
1 answer
204 views

Managed Package - Global interface and global/public class

Let's say we have global ProductFactory class like this: global class ProductFactory { global static ProductService getProductService() { return new ProductServiceBasic(); } } ...
user avatar
  • 2,713
1 vote
2 answers
1k views

Variables in Interface in Salesforce

Can you declare variables in Interface in Apex (Salesforce). In Java, it allows you to declare and initialize variables with public static final keywords in Interface. Also in Apex, are all abstract ...
user avatar
  • 21
2 votes
1 answer
250 views

Where or how can I find what interfaces an out of the box Apex class implements?

Is there a method of discovering (or a place to look up) all of the interfaces that an out of the box Salesforce class (Like LoginHistory) implements? The reason I ask: I'm attempting to test a ...
user avatar
  • 757
1 vote
1 answer
2k views

Lightning Component force:hasSObjectName, sObjectName undefined

Per the force:hasSObjectName interface documentation, I can reference an automatically added attribute named sObjectName to retrieve the object where my custom lightning component is being accessed. ...
user avatar
13 votes
2 answers
2k views

Can create an Instance of Abstract Class, Salesforce Bug?

I was playing with Apex and stumbled upon this. Created an Abstract Class and made the constructor as private, so that noone can create an instance of it. This works just fine during compilation. it ...
user avatar
1 vote
2 answers
1k views

Does Database.SaveResult, Database.DeleteResult, etc. implement a public interface?

The various DML operations (insert, update, delete, etc.) all return results with very similar methods and properties. It is not uncommon, as a developer, that I should want to handle these results ...
user avatar
4 votes
2 answers
2k views

Apex PMD: Avoid empty block statements

Perhaps this isn't the place for this -- but it looks like a good place to start. I'm using Apex PMD code analysis (within Visual Studio Code) and it's throwing off the following for an interface ...
user avatar
  • 321
0 votes
1 answer
73 views

Global Inner Interfaces in managed package

We have an global interface inside a global class: global class SomeClass { global interface someInterface() { //various methods returning and accepting standard Apex objects only String ...
user avatar
  • 611
1 vote
2 answers
225 views

Design pattern for an attachment trigger using trigger framework?

Hoping to tap into the wisdom of the Apex design pattern wizards out there. We have recently moved to a trigger framework in order to decouple and standardize our wildly disparate trigger code ...
user avatar
  • 321
5 votes
1 answer
375 views

Versioning Apex Interfaces in managed packages

As documented in What are the pitfalls around Apex Interfaces in managed packages? a global Apex interface that has been published in a managed package can't be modified. Trying to do so results in ...
user avatar
20 votes
2 answers
763 views

Are Apex interfaces and abstract classes case-sensitive?

My understanding from the docs is that apex class and method names are case-insensitive. I've run across an edge-case with interfaces and abstract classes which appears to be undocumented behavior ...
user avatar
5 votes
2 answers
528 views

What are the risks or drawbacks of creating Parameterized Interfaces using of the Apex API version 25?

Unfortunately, as of API version 26, SFDC removed parameterized interfaces. However, it is relatively easy to create new interfaces and set the version as 25. So, to take the example from ...
user avatar
0 votes
2 answers
95 views

Is there a dictionary of SFDC native interfaces we can leverage in Apex code? [closed]

Interfaces are wonderful for creating reusable code, as well as enabling us to reuse or make better use of the functionality SFDC already provides us. The Apex Developer's Guide tells us how to ...
user avatar
3 votes
1 answer
2k views

Inner Classes/Interfaces

the guide says that one difference between Java and Apex is: Inner classes and interfaces can only be declared one level deep inside an outer class. Considering I know in Java what is an Inner class,...
user avatar
2 votes
1 answer
67 views

Can Interface declare only methods?

I have created the following interface and a class that implements it. global interface SampleInterface { String logicA(); } public class SampleClass implements SampleInterface { public ...
user avatar
0 votes
0 answers
152 views

Invoking AWS CLI from Apex class

I need to invoke AWS Command Line Interface from a apex class. Can someone please help me in that? Thanks.
user avatar
2 votes
0 answers
433 views

Global Interface in managed package

We are building a managed package and we have an understanding gap on the usage of Global Interface in the code. Couple of months back our package was rejected in the security review citing usage of ...
user avatar
  • 21
2 votes
0 answers
176 views

Impossible to add "flexipage:availableForRecordHome" on a component

I'm trying to create a new lightning component that should be displayed on a record page. However the error I'm getting this error when I'm adding the interface Deployment Failed: ...
user avatar
11 votes
1 answer
2k views

How to deserialize into interface type when concrete type is unknown

As a follow up to this question: I am essentially trying to deserialize a JSON object into an Interface Type. Unfortunately we cannot deserialize using an Interface as the ApexType and must know ...
user avatar
  • 53.1k
7 votes
2 answers
2k views

Cannot deserialize JSON as abstract type?

While writing a class to help me manage @future jobs for a project, I stumbled onto an error message I can find very little help on. Cannot deserialize JSON as abstract type I used an interface ...
user avatar
  • 8,543
7 votes
1 answer
1k views

Static method able to be called/executed from class instantiated from type.newInstance() with interface. Expected?

When trying to execute a static method from an instance of a class testMe tmp = New testMe(); tmp.myStaticMethod('a','b'); we get the familiar: Static method cannot be referenced from a non ...
user avatar
  • 53.1k
11 votes
1 answer
3k views

Are Lightning Interfaces (e.g. implements="c:MyInterface") actually useful for anything?

I've been trying to build a Lightning Community where I use component inheritance and interfaces to share certain bits of functionality. For my particular use, composition wouldn't fit as well as ...
user avatar
  • 12.7k
4 votes
1 answer
4k views

How Custom Iterators with Iterable Work

I was reading the topic of using iterator and iterabel Interface - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_iterable.htm It says : If you do not want ...
user avatar
  • 4,521
2 votes
1 answer
234 views

Programmatically list all public/global attributes on a lightning component

Salesforce has provided some new lightning component interfaces to make communities a bit more customizable. They have provided some documentation for these, but it is weak at best: https://...
user avatar
  • 3,942
0 votes
1 answer
824 views

Using interfaces as parameter arguments

Is it possible to use interfaces as parameters within Apex? As an example: public interface InterfaceExample{ void example(InterfaceExample ex); // Will not compile InterfaceExample example2(...
user avatar
  • 1,071
7 votes
1 answer
277 views

Doesn't Set<T> collection implement Iterable<T> interface? [duplicate]

I am trying to join String elements of Set with semicolon. Set<String> elements = new Set<String>{ 'foo', 'bar' }; System.debug(String.join(elements, ';')); getting the ...
user avatar
1 vote
1 answer
251 views

Clearing (or Cleaning) Global Search Cache - False Results - Sharing

How do we get Global Search to NOT show results that are NO LONGER VISIBLE to the logged in user? More quickly? Ever? I'm noticing as we test our implementation in Sandbox that when I login as ...
user avatar
  • 4,564
1 vote
0 answers
43 views

Error: Managed interface that is released can't implement new interfaces (bug?)

I have a managed package with the following class already in it: global class MyInterfaceClass { global interface InnerInterface {} global interface DeepInterface extends InnerInterface {} } ...
user avatar
  • 3,764
1 vote
2 answers
9k views

custom component not showing up in community builder

a custom lightning component I just created is not showing up in my community-community builder custom component list as an option to use. I have had this issue before but forget how to make it ...
user avatar
0 votes
1 answer
26 views

Designed schema and loaded data -- is it possible to build an app that will just visualize this data from custom user requests?

Quick question -- I'm new to salesforce but I tried to dig around and want to 1) check if my understanding is correct and 2) see if something is possible. Basically, I have a schema that I built ...
user avatar
  • 103
-1 votes
1 answer
295 views

what is interface method in salesforce ? How Many types Of Interfaces Is ther In salesforce [duplicate]

what is interface? when using interface? In Salesforce Give Me Explination
user avatar
  • 31
2 votes
1 answer
233 views

Using interfaces from managed package

We have a managed package. In the managed package, we have a button in the application. When the user clicks on the button, we want the customer's specific logic to be executed (which could ...
user avatar
2 votes
1 answer
76 views

Enable collapsible sections for partner users

I have "Enable Collapsible Sections" checked in the User Interface settings. However it currently only works for Users, not Partner Users. Is there a way to enable this for Partner Users too?
user avatar
20 votes
4 answers
10k views

Why use an interface in Apex?

I'm studying for my Platform Dev I exam, and I've been reading about interfaces. I understand how they work in abstraction, but what I don't understand is why you would use them. The documentation ...
user avatar
5 votes
2 answers
1k views

How to Create a Custom App Settings Page?

I would like to create a custom app package that provides the user with a setup interface in which they can input their own preferences, which inputs will then be referenced by apex code. I will be ...
user avatar
21 votes
1 answer
2k views

Abstract, Interface, Classes OH MY - Question on Approach

So I believe that I have a real world use case for an object model that uses abstract classes and interface. I do however have a few questions about the best way to go about it: Interface public ...
user avatar
  • 53.1k