Annotation Interface JsonbSubtype


@JsonbAnnotation @Retention(RUNTIME) @Target({}) public @interface JsonbSubtype
Subtype is tightly bound to the JsonbTypeInfo.
Type defines class which instance will be created when processing specific alias, or when processing instance of the specified type, to determine which alias should be used.
Alias is used instead of a class name. It has to be unique value among all the defined subtypes bound to the specific JsonbTypeInfo. An exception should be thrown when processing and validating aliases and duplicate alias is found.

 // Example
 @JsonbTypeInfo({
      @JsonbSubtype(alias = "dog", type = Dog.class)
      @JsonbSubtype(alias = "cat", type = Cat.class)
 })
 interface Animal {}

 class Dog implements Animal {
     public String isDog = true;
 }
 class Cat implements Animal {
     public String isCat = true;
 }
 class Rat implements Animal {
     public String isRat = true;
 }

 jsonb.toJson(new Dog());// {"@type":"dog","isDog":true}
 jsonb.toJson(new Cat());// {"@type":"cat","isCat":true}
 jsonb.toJson(new Rat());// {"isRat":true}