Skip to content

Annotations

Max edited this page Oct 27, 2023 · 4 revisions

When using annotations inside of amber, we can break them down into different categories.

Path Annotations

These annotations are used to tell amber where to put things inside of your configuration files. An example of a path annotation is:

@Path("customers")

or

@Intrinsic

You need to have a path annotation in order for your function to be proxied over to the resource container and pulled from. The YAML file for this type of annotation looks like:

customers:
  yourvalue: "Hello"

and for intrinsic pathways

yourvalue: "Hello"

Identification Annotations

There is only one annotation when using identification, and that is

@EntryName("bob")

What this does is it tells amber what to name your YAML entry as. In this example, it would look like:

bob: value

Defaults

Most localization libraries that use the same methods that I am only support strings, but using amber you can use most primitive types that are commonly used in configurations. The annotations go as followed:

@DefaultString("Hey")
@DefaultInteger(20)
@DefaultBoolean(true)
@DefaultLong(1000L)
@DefaultDouble(2.2)

In order to utilize all of these annotations, you must ensure that your return type is the same as the type of default you are targeting. An example of this is:

@Intrinsic
@EntryName("cookies")
@DefaultInteger(2)
fun onCookiesFetch() : Int

This will return the proper value when accessing it from a code standpoint.

Clone this wiki locally