Skip to main content

PARTs Preferences

Explanation & History

PARTs Preferences is a wrapper and handler for the WPI Lib Preferences feature. There are two parts to this feature, PARTs Preferences, and PARTs Preference. PARTs Preference is the object that handles the preference's type of data, and its key, or label with easy methods to get the value back. PARTs Preferences is the manager of each preference. In each subsystem, a PARTs Preferences instance is created. With this instance, preferences can be created and retrieved. This feature is automatically set up in our PARTs Subsystem.

Code Example

package;

// Import the PARTs Preferences class.
import org.parts3492.partslib.PARTsPreferences;

public class MyClass {
    
    public MyClass() {
        super();

        // Create new PARTs Preferences manager.
        // Keep in mind that this is not required in a PARTsSubsystem, as it already has one built in.
        PARTsPreferences partsPrefrences = new PARTsPreferences();

        // Create our preferences.
        // Each type is an overload, or version of the same function.
        partsPrefrences.addPreference("MyBoolean", true);
        partsPrefrences.addPreference("MyInt", 42);
        partsPrefrences.addPreference("MyDouble", 3.14);
        partsPrefrences.addPreference("MyFloat", 1.23f);
        partsPrefrences.addPreference("MyString", "MyValue");
    }
}