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

Last change on this file since 659 was 579, checked in by wouter, 18 months ago

#159 working on handling overriding comments. Some comments are unfortunately completely missed/dropped by javaparser.

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