Skip to content

Latest commit

 

History

History
27 lines (20 loc) · 741 Bytes

File metadata and controls

27 lines (20 loc) · 741 Bytes
title @RefinementAlias
parent Annotations
nav_order 2
permalink /annotations/refinement-alias/
description Learn how to reuse common refinement predicates with aliases to keep contracts shorter and easier to maintain.

@RefinementAlias

When the same refinement appears repeatedly, you can define it once with @RefinementAlias and reuse it inside other refinements.

import liquidjava.specification.*;

@RefinementAlias("Percentage(int v) { 0 <= v && v <= 100 }")
public class MyClass {

    @Refinement("Percentage(x)")
    int x = 25;

    @Refinement("Percentage(y)")
    int y = 75;
}

This helps keep contracts shorter and easier to maintain by replacing repeated predicates with a domain-specific alias.