Context [WIP not up to date]
Some YAPION annotation have a context array, that you can specify if desired. This is useful to create specific views onto a given object. You can use this for some api system as an example or just to load fewer data than you save. You can provide a context to either the YAPIONSerializer or YAPIONDeserializer as a String.
import yapion.annotations.deserialize.YAPIONLoad;
import yapion.annotations.serialize.YAPIONSave;
import yapion.serializing.YAPIONSerializer;
@YAPIONSave
@YAPIONLoad
public class ExampleContext {
@YAPIONSave
private long time = System.currentTimeMillis();
@YAPIONSave
@YAPIONLoad
private int number = 0;
@YAPIONSave(context = "test")
private int numberTwo = 0;
@YAPIONSave(context = {"test", "test2"})
private int numberThree = 0;
public static void main(String[] args) {
YAPIONSerializer.serialize(new ExampleContext());
YAPIONSerializer.serialize(new ExampleContext(), "test");
YAPIONSerializer.serialize(new ExampleContext(), "test2");
}
}
Context Management rules:
- Empty context or no context to the call of serialization or deserialization will result in a save
- Annotation context array is empty will result in a save
- If one annotation context entry is either empty or ‘*’ it will result in a save
- If one annotation context entry is equal to the context passed to the serialization or deserialization call it will result in a save