Annotation Interface MaxMindDbCreator
MaxMindDbCreator is an annotation that can be used to mark a static factory
method or constructor that should be used to create an instance of a class from a
decoded value when decoding a MaxMind DB file.
This is similar to Jackson's @JsonCreator annotation and is useful for
types that need custom deserialization logic, such as enums with non-standard
string representations.
Example usage:
public enum ConnectionType {
DIALUP("Dialup"),
CABLE_DSL("Cable/DSL");
private final String name;
ConnectionType(String name) {
this.name = name;
}
@MaxMindDbCreator
public static ConnectionType fromString(String s) {
return switch (s) {
case "Dialup" -> DIALUP;
case "Cable/DSL" -> CABLE_DSL;
default -> null;
};
}
}