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

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

#291 move annotation to above the javadoc

File size: 2.5 KB
RevLine 
[519]1package geniusweb.profile;
2
[804]3import org.eclipse.jdt.annotation.NonNull;
4
[519]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 {
[818]15 private final @NonNull String name;
16 private final @NonNull Domain domain;
[519]17 private final Bid reservationbid;
18
[825]19 @JsonCreator
[519]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 */
[818]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");
[519]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
[804]45 public @NonNull String getName() {
[519]46 return name;
47 }
48
49 @Override
[804]50 public @NonNull Domain getDomain() {
[519]51 return domain;
52 }
53
54 @Override
55 public Bid getReservationBid() {
56 return reservationbid;
57 }
58
[825]59 @NonNull
[519]60 /**
61 *
62 * @return string of values contained in here. Useful to make derived
63 * toString functions
64 */
[825]65 public String getValuesString() {
[519]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.