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.
72
questions
0
votes
0
answers
89
views
QuickAction.QuickActionDefaultsHandler Implementation
Requirement is to populated 'To' field with specific email addresses when user uses action in feed tab. Problem occurs when user click first 'Reply All' from chatter feed to reply to email message. ...
0
votes
0
answers
30
views
run a script in the the developer console while implementing interface [duplicate]
I'm trying to run a script from the developer console with the queueable interface implemented, but the execute method isn't called.
code to put in Execute Anonymous Window in the developer console:
...
0
votes
1
answer
232
views
how to develop custom interface in LWC or any alternate of <Aura:interface in LWC
In our project aura:interface is using to render data from multiple child aura:component, now we want to include LWC component as well as child component. Is there any way to implement similar flow as ...
2
votes
0
answers
349
views
Not able to access interface methods from an abstract class instance
I'm trying to build an Apex classes structure where I have two (or more) entities that have something in common but at the same time have a different set of fields. In the example below it's gonna be ...
3
votes
1
answer
1k
views
How do I create a List with a dynamic type?
I have a generic method that sets up some objects and returns a list of them. The type of the object is defined by an interface.
The interface:
public interface DynamicThing {
DynamicThing ...
0
votes
1
answer
195
views
Custom iterator: Inserting elements into the list being iterated over
I have the following custom iterator class that iterates over a list of Accounts (accounts):
public class CustomIterator implements Iterator<Account>{
private List<Account> ...
2
votes
1
answer
285
views
Error:Invalid conversion from runtime type Map<String,ANY> to List<ANY> Class
Here is my request json.
{
"apply_header":" CER202208170008",
"sn":"CERL202208170008",
"cert_cat":"MCS",
"cert_name":&...
7
votes
1
answer
336
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 ...
-3
votes
1
answer
165
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 ...
7
votes
1
answer
3k
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 ...
17
votes
1
answer
1k
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 ...
6
votes
1
answer
770
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)...
2
votes
1
answer
354
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 ...
2
votes
1
answer
404
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 ...
2
votes
1
answer
291
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 ...
2
votes
1
answer
301
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(...
0
votes
1
answer
295
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, ...
1
vote
0
answers
29
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 ...
5
votes
2
answers
736
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 {
...
}
...
2
votes
2
answers
593
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 ...
1
vote
1
answer
793
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
2
votes
1
answer
342
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();
}
}
...
1
vote
2
answers
2k
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 ...
2
votes
1
answer
339
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 ...
1
vote
1
answer
3k
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. ...
15
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 ...
1
vote
2
answers
2k
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 ...
4
votes
2
answers
4k
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 ...
0
votes
1
answer
104
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 ...
1
vote
2
answers
336
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 ...
5
votes
1
answer
477
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 ...
20
votes
2
answers
871
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 ...
6
votes
2
answers
655
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 ...
0
votes
2
answers
136
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 ...
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,...
2
votes
1
answer
120
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 ...
0
votes
0
answers
285
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.
2
votes
0
answers
573
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 ...
2
votes
0
answers
205
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: ...
11
votes
1
answer
3k
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 ...
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 ...
7
votes
2
answers
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 ...
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 ...
4
votes
1
answer
6k
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 ...
2
votes
1
answer
283
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://...
0
votes
1
answer
1k
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(...
7
votes
1
answer
312
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 ...
1
vote
1
answer
466
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 ...
1
vote
0
answers
54
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 {}
}
...
1
vote
2
answers
11k
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 ...