source: java2python/geniuswebtranslator/geniuswebsrc/geniusweb/profile/DefaultProfile.java@ 889

Last change on this file since 889 was 825, checked in by wouter, 5 months ago

#291 move annotation to above the javadoc

File size: 2.5 KB
Line 
1package geniusweb.profile;
2
3import org.eclipse.jdt.annotation.NonNull;
4
5import com.fasterxml.jackson.annotation.JsonCreator;
6
7import geniusweb.issuevalue.Bid;
8import geniusweb.issuevalue.Domain;
9
10/**
11 * Set up such that jackson can look at the getters.
12 *
13 */
14public abstract class DefaultProfile implements Profile {
15 private final @NonNull String name;
16 private final @NonNull Domain domain;
17 private final Bid reservationbid;
18
19 @JsonCreator
20 /**
21 *
22 * @param name the name for the profile
23 * @param domain the {@link Domain} description
24 * @param reservationbid the reservation {@link Bid}
25 */
26 public DefaultProfile(@NonNull String name, @NonNull Domain domain,
27 Bid reservationbid) {
28 if (name == null)
29 throw new NullPointerException("name must be not null");
30 if (domain == null)
31 throw new NullPointerException("domain must be not null");
32 this.name = name;
33 this.domain = domain;
34 this.reservationbid = reservationbid;
35 if (reservationbid != null) {
36 String message = domain.isFitting(reservationbid);
37 if (message != null)
38 throw new IllegalArgumentException(
39 "reservationbid is not fitting domain: " + message);
40 }
41
42 }
43
44 @Override
45 public @NonNull String getName() {
46 return name;
47 }
48
49 @Override
50 public @NonNull Domain getDomain() {
51 return domain;
52 }
53
54 @Override
55 public Bid getReservationBid() {
56 return reservationbid;
57 }
58
59 @NonNull
60 /**
61 *
62 * @return string of values contained in here. Useful to make derived
63 * toString functions
64 */
65 public String getValuesString() {
66 return name + "," + domain + "," + reservationbid;
67 }
68
69 @Override
70 public int hashCode() {
71 final int prime = 31;
72 int result = 1;
73 result = prime * result + ((domain == null) ? 0 : domain.hashCode());
74 result = prime * result + ((name == null) ? 0 : name.hashCode());
75 result = prime * result
76 + ((reservationbid == null) ? 0 : reservationbid.hashCode());
77 return result;
78 }
79
80 @Override
81 public boolean equals(Object obj) {
82 if (this == obj)
83 return true;
84 if (obj == null)
85 return false;
86 if (getClass() != obj.getClass())
87 return false;
88 DefaultProfile other = (DefaultProfile) obj;
89 if (domain == null) {
90 if (other.domain != null)
91 return false;
92 } else if (!domain.equals(other.domain))
93 return false;
94 if (name == null) {
95 if (other.name != null)
96 return false;
97 } else if (!name.equals(other.name))
98 return false;
99 if (reservationbid == null) {
100 if (other.reservationbid != null)
101 return false;
102 } else if (!reservationbid.equals(other.reservationbid))
103 return false;
104 return true;
105 }
106
107}
Note: See TracBrowser for help on using the repository browser.