Module jdk.jfr
Package jdk.jfr

Annotation Interface Relational


@Retention(RUNTIME) @Target(ANNOTATION_TYPE) public @interface Relational
Meta annotation for relational annotations, to be used on an annotation.

The following example shows how a relational annotation can be created and used. The Orderid annotation indicates there is a relation between OrderEvent and OrderLineEvent. if they have the same ID, the order line belongs to the order.

@MetadataDefinition
@Relational
@Name("com.example.OrderId")
@Label("Order ID")
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface OrderId {
}

@Name("com.example.Order")
@Label("Order")
@Category("Orders")
class OrderEvent extends Event {
    @Label("Order ID")
    @OrderId
    long orderId;

    @Label("Order Date")
    @Timestamp
    long orderDate;
}

@Name("com.example.OrderLine")
@Label("Order Line")
@Category("Orders")
class OrderLineEvent extends Event {
    @Label("Order ID")
    @OrderId
    long orderId;

    @Label("Quantity")
    long quantity;

    @Label("Product")
    String product;
}
Since:
9