-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAccount.java
More file actions
87 lines (67 loc) · 1.81 KB
/
Copy pathAccount.java
File metadata and controls
87 lines (67 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.salimov.yurii.lesson07.task02;
import javax.persistence.*;
@Entity
@Table(name = "Accounts")
public final class Account {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable = false)
private long id;
@Column(name = "number", nullable = false)
private long number;
@Column(name = "type", nullable = false)
private String type;
@Column(name = "value", nullable = false)
private double value;
@ManyToOne
@JoinColumn(name = "profile_id")
private Profile profile;
public Account() {
}
public Account(final long number, final String type) {
this();
this.number = number;
this.type = type;
}
@Override
public String toString() {
return "Account id = " + this.id + ":" +
"\n\tnumber - " + this.number +
"\n\ttype - " + this.type +
"\n\tvalue - " + this.value +
"\n\tprofile id = " + this.profile.getId();
}
public void setId(final long id) {
this.id = id;
}
public long getId() {
return this.id;
}
public void setNumber(final long number) {
this.number = number;
}
public long getNumber() {
return this.number;
}
public void setType(final String type) {
this.type = type;
}
public String getType() {
return this.type;
}
public void setValue(final double value) {
this.value = value;
}
public double getValue() {
return this.value;
}
public void setProfile(final Profile profile) {
this.profile = profile;
if (!profile.getAccounts().contains(this)) {
profile.addAccount(this);
}
}
public Profile getProfile() {
return this.profile;
}
}