Skip to content

Commit 7652fd9

Browse files
committed
Update Refinement Aliases Section
1 parent 8af5236 commit 7652fd9

1 file changed

Lines changed: 6 additions & 19 deletions

File tree

reference/refinement-aliases.md

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff 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 }")
1615
public 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.

0 commit comments

Comments
 (0)