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

Last change on this file since 804 was 804, checked in by wouter, 6 months ago

#278 added NonNull annotation in many places in the geniusweb code

File size: 2.3 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 String name;
16 private final Domain domain;
17 private final Bid reservationbid;
18
19 /**
20 *
21 * @param name the name for the profile
22 * @param domain the {@link Domain} description
23 * @param reservationbid the reservation {@link Bid}
24 */
25 @JsonCreator
26 public DefaultProfile(String name, Domain domain, Bid reservationbid) {
27 this.name = name;
28 this.domain = domain;
29 this.reservationbid = reservationbid;
30 if (reservationbid != null) {
31 String message = domain.isFitting(reservationbid);
32 if (message != null)
33 throw new IllegalArgumentException(
34 "reservationbid is not fitting domain: " + message);
35 }
36
37 }
38
39 @Override
40 public @NonNull String getName() {
41 return name;
42 }
43
44 @Override
45 public @NonNull Domain getDomain() {
46 return domain;
47 }
48
49 @Override
50 public Bid getReservationBid() {
51 return reservationbid;
52 }
53
54 /**
55 *
56 * @return string of values contained in here. Useful to make derived
57 * toString functions
58 */
59 public @NonNull String getValuesString() {
60 return name + "," + domain + "," + reservationbid;
61 }
62
63 @Override
64 public int hashCode() {
65 final int prime = 31;
66 int result = 1;
67 result = prime * result + ((domain == null) ? 0 : domain.hashCode());
68 result = prime * result + ((name == null) ? 0 : name.hashCode());
69 result = prime * result
70 + ((reservationbid == null) ? 0 : reservationbid.hashCode());
71 return result;
72 }
73
74 @Override
75 public boolean equals(Object obj) {
76 if (this == obj)
77 return true;
78 if (obj == null)
79 return false;
80 if (getClass() != obj.getClass())
81 return false;
82 DefaultProfile other = (DefaultProfile) obj;
83 if (domain == null) {
84 if (other.domain != null)
85 return false;
86 } else if (!domain.equals(other.domain))
87 return false;
88 if (name == null) {
89 if (other.name != null)
90 return false;
91 } else if (!name.equals(other.name))
92 return false;
93 if (reservationbid == null) {
94 if (other.reservationbid != null)
95 return false;
96 } else if (!reservationbid.equals(other.reservationbid))
97 return false;
98 return true;
99 }
100
101}
Note: See TracBrowser for help on using the repository browser.