LibJF/libjf-config-v0/src/main/java/io/gitlab/jfronny/libjf/config/api/EntryInfo.java

70 lines
1.6 KiB
Java
Raw Normal View History

2022-04-29 15:48:27 +02:00
package io.gitlab.jfronny.libjf.config.api;
import io.gitlab.jfronny.gson.JsonElement;
import io.gitlab.jfronny.gson.stream.JsonWriter;
import java.io.IOException;
2022-04-29 16:07:12 +02:00
public interface EntryInfo<T> {
2022-04-29 15:48:27 +02:00
/**
* @return Get the default value of this entry
*/
T getDefault();
/**
* Gets the current value
* @return The current value
*/
T getValue() throws IllegalAccessException;
/**
* Set the current value to the parameter
* @param value The value to use
*/
void setValue(T value) throws IllegalAccessException;
/**
* Get the value type of this entry. Will use the class definition, not the current value
* @return The type of this entry
*/
Class<T> getValueType();
/**
* Ensure the current value is within expected bounds.
*/
void fix();
/**
* Get the name of this entry
* @return This entry's name
*/
String getName();
/**
* Set this entry's value to that of the element
* @param element The element to read from
*/
void loadFromJson(JsonElement element) throws IllegalAccessException;
/**
* Write the currently cached value to the writer
* @param writer The writer to write to
*/
void writeTo(JsonWriter writer, String translationPrefix) throws IOException, IllegalAccessException;
/**
2022-04-29 16:07:12 +02:00
* @return Get the width for this entry
2022-04-29 15:48:27 +02:00
*/
2022-04-29 16:07:12 +02:00
int getWidth();
2022-04-29 15:48:27 +02:00
/**
2022-04-29 16:07:12 +02:00
* @return Get the minimum value of this entry
2022-04-29 15:48:27 +02:00
*/
2022-04-29 16:07:12 +02:00
double getMinValue();
2022-04-29 15:48:27 +02:00
2022-04-29 16:07:12 +02:00
/**
* @return Get the maximum value for this entry
*/
double getMaxValue();
2022-04-29 15:48:27 +02:00
}