File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .zetcode ;
2+
3+ import javax .validation .constraints .Max ;
4+ import javax .validation .constraints .Min ;
5+ import javax .validation .constraints .NotNull ;
6+ import javax .validation .constraints .Size ;
7+
8+ public class Car {
9+
10+ private Long Id ;
11+
12+ @ NotNull
13+ @ Size (min = 4 , max = 50 )
14+ private String name ;
15+
16+ @ Min (value = 1000 )
17+ @ Max (value = 5000000 , message = "There is no such expensive car" )
18+ private int price ;
19+
20+ public Car (String name , int price ) {
21+
22+ this .name = name ;
23+ this .price = price ;
24+ }
25+
26+ public Long getId () {
27+ return Id ;
28+ }
29+
30+ public void setId (Long id ) {
31+ Id = id ;
32+ }
33+
34+ public String getName () {
35+ return name ;
36+ }
37+
38+ public void setName (String name ) {
39+ this .name = name ;
40+ }
41+
42+ public int getPrice () {
43+ return price ;
44+ }
45+
46+ public void setPrice (int price ) {
47+ this .price = price ;
48+ }
49+
50+ @ Override
51+ public String toString () {
52+
53+ final StringBuilder sb = new StringBuilder ("Car{" );
54+ sb .append ("Id=" ).append (Id );
55+ sb .append (", name='" ).append (name ).append ('\'' );
56+ sb .append (", price=" ).append (price );
57+ sb .append ('}' );
58+ return sb .toString ();
59+ }
60+ }
You can’t perform that action at this time.
0 commit comments