New paste Use cases Explore public pastes Text tools Developer API The Paste Library Security Sign in with Google
JAVAExample pasteCreated 2026-08-012 viewsNo expiry

Java record with input validation

Raw New paste
javaRead-only
1
public record PageRequest(int page, int size) {
    public PageRequest {
        if (page < 1) {
            throw new IllegalArgumentException("page must be positive");
        }
        if (size < 1 || size > 100) {
            throw new IllegalArgumentException("size must be between 1 and 100");
        }
    }

    public int offset() {
        return (page - 1) * size;
    }
}
Report abuse

Paste details

Visibility
Public
Size
384 bytes
Protection
Standard link access
Retention
No automatic expiry

Share with confidence

Unlisted links are not searchable, but anyone with the URL can open them. Never paste live credentials or personal data.