crowlogic / arb4j

arb4j is a Java API for the arbitrary precision ball arithmetic library found at http://arblib.org
Other
1 stars 0 forks source link

analyzer: save and load via YAML (annotations) #509

Closed crowlogic closed 1 month ago

crowlogic commented 1 month ago

this library provides annotations for skipping properties during serialization/deserialization with SnakeYAML. Here are the key points about skipping properties with snakeyaml-anno:

  1. You can use the @YamlProperty annotation with skipAtLoad = true to skip a property during deserialization (loading):
public class Person {
   @YamlProperty(skipAtLoad = true)     
   public String name;
}
  1. You can use skipAtDump = true to skip a property during serialization (dumping):
public class Person {
   @YamlProperty(skipAtDump = true)     
   public String name;
}
  1. There's also a skipAtDumpIf option to conditionally skip properties during dumping based on a predicate:
public class Person {
   @YamlProperty(skipAtDumpIf = SkipIfNull.class)     
   public String name;
}
  1. By default, empty/null properties are skipped during dumping globally. This can be changed when creating the AnnotationAwareRepresenter:
Yaml yaml = new Yaml(new AnnotationAwareRepresenter(false)); // Don't skip empty properties globally
  1. The library provides predefined SkipIfNull and SkipIfEmpty predicates for common skipping logic.

To use these annotations in your project, you would need to add the snakeyaml-anno dependency and use the AnnotationAwareConstructor and AnnotationAwareRepresenter when creating your Yaml instance. This would allow you to use the @YamlProperty annotations to control skipping of properties during serialization and deserialization.