Questions tagged [inner-class]

An inner class or nested class is a class declared entirely within the body of another class or interface. It is distinguished from a subclass.

Filter by
Sorted by
Tagged with
0
votes
1answer
30 views

Variable to hold the return of type wrapper class from a method

I have a class and a method. In the method I am calling another method of another class - Class2.Method2 The return type of method 2 is a wrapper class. What should be the variable type in my method 1 ...
1
vote
0answers
29 views

Complex type passed by aura component to apex method

we have this inner class: public class Documents { @AuraEnabled public String type; @AuraEnabled public List<Custom_Document__c> documents; } And we use it in a method declared like ...
0
votes
1answer
52 views

How do I call this method inside of inner class

Hello im really confused about how to call requestBody(Id quoteId) inside this code I created using inner classes: public class PT_Interface{ public class Request_Model { public ...
5
votes
2answers
189 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 { ... } ...
0
votes
1answer
64 views

How to make a Json object a subclass

I have a Json Object which I created with the online JSON to apex tool. This works a a separate class how can i make this a subclass. I get the error: Inner types are not allowed to have inner ...
1
vote
2answers
497 views

Populate Apex Inner Class Variables in Lightning Web Component

Need a help in Lightning Web Components. I am working on an assignment where I need to get some values from the UI, populate it on an inner class variables defined in an Apex class and then make a web ...
3
votes
2answers
326 views

Best Practice deserialize a JSON to avoid heap size limit

I'm sending an HTTP request to get a JSON of Students. The JSON is a complex JSON with arrays and its break into 3 objects in Salesforce. I'm using a class (JSON2APEX) to deserialize the JSON. Some ...
8
votes
1answer
252 views

Managed package patches - can a public inner class be added?

In the Create and Upload Patches documentation, there is no mention of restrictions on adding inner classes to an already packaged top-level class. The restrictions listed are: You can’t add package ...
4
votes
1answer
83 views

Inherited sharing question in nested inner classes

The sharing documentation Using the with sharing, without sharing, and inherited sharing Keywords says: The sharing setting of the class where the method is defined is applied, not of the class where ...
1
vote
1answer
63 views

Sending Inner class as a param from Queueable apex to a batch

I have a queueable apex that calls to a batch. Inside the queueable class - I have inner Class that writes a log with incorrect fields. The Inner Class inside the queueable class : public class ...
0
votes
1answer
59 views

Complex JSON Parsing - Beware

Not for the faint of heart. Trying to do a Scalyr integration, and wrestling with some pretty difficult JSON. I have used JSON2Apex which generated several inner classes, and the Apex and JSON are ...
0
votes
1answer
76 views

Deserialization using Apex class generated using JSON2Apex gives null for inner values

I have the following piece of code. @RestResource(urlMapping='/Update') global with sharing class OpportunityUpdate { @HttpPost global static void updateOpportunity() { RestRequest req = ...
0
votes
1answer
177 views

LWC: Error accessing Inner class from javascript

Im running into the following javascript error when trying to display inner class data on my LWC. This was working fine until I added ".data" to my output variables for employerAddress to resolve ...
1
vote
1answer
487 views

LWC inner class property access issue

Im receiving the following error when trying to initialize the OnboardingPeopleResult class from a button on my LWC form. This data object initializes an inner class OnboardingAddressResult as one if ...
1
vote
1answer
96 views

How to test an inner class?

I did my research, but could not find a clear guidelines on how to test an inner class. This is my inner class: public class ExistingAccountResult{ public String salesforceaccountid {get;set;} ...
0
votes
1answer
65 views

Invalid type when creating a map of <string, list<innerclassobject>>

Invalid type: EcPerformanceRecordList I want to create a Map of userid and list of sObject records, then loop through this map so that I can count how many apps have been submitted per user....
0
votes
1answer
49 views

Clone a map containing an inner class so it passes by value and not reference?

I have a map<string, InnerClass>, where the inner apex class containing no sObjects, just a bunch of simple variable types like booleans, integers and strings. (It also contains another inner ...
4
votes
3answers
413 views

Adding a Wrapper Class to an External Class

I am confused about what is happening in a small section of some code. I have a class that has a wrapper class inside it. There is an external class that calls this wrapper class Models.add(new ...
3
votes
1answer
787 views

How to use inner class / wrapper class as scope in Apex Batch

I already successfully collecting the list of data from callout another system as json body to the inner class to accomodate custom information: Here is the apex class of the inner class: public ...
3
votes
1answer
1k 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,...
3
votes
1answer
150 views

apex: Innerclass not not available in map in outside class

I have the following setup: public with sharing class MyOuterClass extends BaseClass { public class MyInnerClass { public Id classId {get; private set;} public MyInnerClass() {} ...
0
votes
0answers
62 views

Why do we need inner classes? [duplicate]

Can anyone give me an example when an inner class is used. I started with wrapper class and found inner class is used in that but as i am all new to this i was thinking if anyone can give me an ...
0
votes
0answers
34 views

Parsing the following JSON response

I need to parse the PRIM_CITYAC,PRIM_STATEAC,PRIM_COUNTRY_NMAC from the following response. I'm very new to REST API. I've create inner class with list in order to obtain the values. Now i got those ...
0
votes
1answer
567 views

how to intialize array for inner class and assign mulitple values to that class?

I have developed vf page which have page block table displaying 3 fields. I tried to modify it with use of apex :repeat so that i have created one inner class as public class outer{ public ...
12
votes
2answers
2k views

Confirmation that (inner) classes are still not fully supported in @AuraEnabled methods?

When writing a controller for a Lightning Component, it is convenient to add the data transfer object classes as inner classes of the controller. This works fine for sending data to the client but I ...
2
votes
1answer
2k views

Nested Inner Classes creation in an apex class

Below is the structure am trying to build. Its throwing Error: Compile Error: unexpected token: 'class' public class maincls { public class test1 { public String teststr {get; set;...
0
votes
2answers
935 views

How to increment a integer value in wrapper class

i have a scenario, i want to increment a value in wrapper class let's take testWrapper class is there , having a Integer variable called incrementX For ex 5 records are there , 1st Recorde --> ...
8
votes
1answer
397 views

Problem using Protected modifier to expose method to inner class

I have a use case where I will have an Apex Class wrapping an sObject, and I need to be able to swap out certain internal functionality based on certain conditions. My plan is to use an few inner ...
3
votes
1answer
731 views

Instance method clashes with static method

I am working with Apex inner classes and I got the limitation described below I can't name a method in my inner class with the same name I used in a static method in the containing class When I do ...
0
votes
1answer
27 views

Error in page controller [closed]

I'm new to APEX, so I'm going through the workbook. Got to the page about 'Using Inner Classes in an APEX Controller'. As far as I can tell, the code I've written replicates what the tutorial has ...
0
votes
1answer
39 views

how to retrive list from inner class

class code: public list<innerclass> inclass= new list<innerclass>(); public class innerclass { public string accountid{get; set;} public string accountname{get; set;} ...
3
votes
2answers
4k views

For loop within for loop

I have a custom object record with a start date, an end date, and a amount field. I want to be able to take the difference between the two dates in number of months, divide the amount by the ...
4
votes
1answer
851 views

Code Coverage on Inner Class/Variable Declarations

When we use an inner class, fields will not be covered unless otherwise we declare them with {get;set;}(even though they are accessible from the test class) Also these lines are not get counted as to ...
9
votes
2answers
9k views

Purpose of an inner class

I've read in the Apex Workbook and the Apex Developer Guide the mention of inner classes. What is their purpose? I see in the Apex Workbook that they used private variables and setter/getter methods ...
0
votes
1answer
300 views

how to assign data from Inner class to out class

i have succesfully parse my JSON data. but now i want data back from following APEX method "getCustomerData()" like below: DxModel[id=2, email=asd@GMAIL.COM, first_name=clerk, last_name=dx, ...
6
votes
1answer
1k views

Possible to declare static constants in an inner class?

I want to define an outer class with two inner classes, the inner classes containing specific constants related to each of them. For example: public class Stuff{ public class Letters{ ...
3
votes
1answer
374 views

Implementing CompareTo In An Inner Class That Needs Outer Class Data

I'm using Apex and VisualForce to make an "open house event check-in page" for a department. For various reasons pertaining to AppExchange plugin compatibility, we are storing a separate "Event" ...
2
votes
1answer
507 views

Why Don't Visualforce Wrapper Class Getter/Setter Methods Not Exist?

I have a wrapper/inner class like so: public class parameter{ public String source { get; set; } public Integer year { get; set; } public String field { get; set; } public parameter(...
13
votes
3answers
1k views

What's It Called: Inner Class Without Sharing?

I believe I have heard a specific term for this pattern, but I am not able to retrieve it from the foggy banks of my memory: public with sharing class OuterClass { public without sharing class ...
10
votes
1answer
648 views

Why are static variables allowed only in outer classes?

According to the documentation, static variables are allowed only in outer classes. Why is that? Is it because you'd need to instantiate the inner class first?