• 1Installation
  • 2Preliminary Knowledge
  • 3Cache Management
  • 4Config Service
  • 5Config Handlers
  • 6Read Configuration
  • 7Write Configuration
  • 8Integrations

Config.apex

  • Docs
  • Tutorials
Getting started with Config.apex

10 min 30 sec

Preliminary Knowledge

It's recommended that you have a fair amount of knowledge on R.apex, but it's not required.

Config.apex uses Func objects from R.apex, and a Func is actually a custom Apex object that mimics the behavior of a function.

Here is how your implement a custom Func.

public class HelloWorldFunc extends Func {
    public HelloWorldFunc() {
        super(0); // specify the number of arguments the Func takes
    }

    // Provide custom implementation for a Func that takes 0 arguments.
    public override Object exec() {
        return 'Hello World';
    }
}
​x
 
1
public class HelloWorldFunc extends Func {
2
    public HelloWorldFunc() {
3
        super(0); // specify the number of arguments the Func takes
4
    }
5
​
6
    // Provide custom implementation for a Func that takes 0 arguments.
7
    public override Object exec() {
8
        return 'Hello World';
9
    }
10
}

And then you instantiate, and invoke it.

Func helloworld = new HelloWorldFunc();
String msg = (String)helloworld.run();
2
 
1
Func helloworld = new HelloWorldFunc();
2
String msg = (String)helloworld.run();

To get deeper with Func objects, please check R.apex.

Done
Copy