Interface ValueWriter

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

Represents a writer of field values for specific config type. Bellow everything about the input of the write method is explained.

The key is the identifier of the value e.g. key=value ( syntax of a .properties configuration )

The values inputted can be any of the following:

  • Map of String as a key and Object as a value
  • List of whatever Object
  • All of java's primitive values (string, int, boolean, byte, etc.)
The method has to handle the inputted value's type by its own and then write it to the PrintWriter writer with the appropriate syntax for the specific config type.

If you want, you can make stuff from your writer mutable by the CustomOptions. A ConfigResolver contains such an instance, which in there you can manipulate any options.

The boolean value sectionExists represents if the method has to write specially about an object, annotated with ConfigObject. For an example, this is a configuration section in YAML:

   messages:
     no-permission: "You don't have permission to perform this."
     information-process: "We're processing the information. Please wait...."
 
In this situation, sectionExists will tell you if you are writing no-permission under messages, or just as a regular value.

Currently, sectionExists will always return "false", this boolean value might be removed in a future release.

In the end we want this to generate clean writes and configs.

Since:
2.0.0
Author:
MrIvanPlays
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    write(String key, Object value, PrintWriter writer, CustomOptions options, boolean sectionExists)