File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,33 +6,20 @@ nav_order: 2
66
77# Refinement Aliases
88
9- When the same refinement appears repeatedly, define it once with ` @RefinementAlias ` and reuse it inside other refinements.
9+ When the same refinement appears repeatedly, we can define it once with ` @RefinementAlias ` and reuse it inside other refinements.
1010
1111``` java
12- import liquidjava.specification.Refinement ;
13- import liquidjava.specification.RefinementAlias ;
12+ import liquidjava.specification.* ;
1413
1514@RefinementAlias (" Percentage(int v) { 0 <= v && v <= 100 }" )
1615public class MyClass {
1716
1817 @Refinement (" Percentage(x)" )
1918 int x = 25 ;
19+
20+ @Refinement (" Percentage(y)" )
21+ int y = 75 ;
2022}
2123```
2224
23- Aliases help by:
24-
25- - reducing repeated predicate text
26- - making refinements easier to read
27- - giving common constraints a domain-specific name
28-
29- ## When to Use Them
30-
31- Aliases are a good fit for constraints such as:
32-
33- - percentages
34- - bounded indexes
35- - value classes such as positive or non-negative integers
36- - project-wide concepts that appear in many files
37-
38- For object protocols, move on to [ State Refinements] ({{ '/reference/state-refinements/' | relative_url }}).
25+ This helps keep contracts shorter and easier to maintain by giving common constraints a domain-specific name.
You can’t perform that action at this time.
0 commit comments