|
| 1 | +from src.java_model import Field, JavaClass |
| 2 | + |
| 3 | +package_example = "expected.DataTypes" |
| 4 | +field_name_string = Field(name="name", type="String", description="This contains name.") |
| 5 | +field_age_int = Field(name="age", type="int", description="This contains age.") |
| 6 | +field_birthdate_date = Field(name="birthDate", type="Date") |
| 7 | +field_additionalInfo_CustomObject = Field(name="additionalInfo", type="CustomData") |
| 8 | + |
| 9 | +person_class_fields = [field_name_string, field_age_int, field_birthdate_date, field_additionalInfo_CustomObject] |
| 10 | + |
| 11 | +class_person = JavaClass(name="Person", fields=person_class_fields, description="Contains information about a person.") |
| 12 | +class_heartbeat = JavaClass(name="Heartbeat", fields=[]) |
| 13 | + |
| 14 | +expected_java_class_person = """\ |
| 15 | +package expected.DataTypes; |
| 16 | +
|
| 17 | +
|
| 18 | +import java.util.Date; |
| 19 | +import java.util.Objects; |
| 20 | +
|
| 21 | +
|
| 22 | +/** |
| 23 | + * Contains information about a person. |
| 24 | + */ |
| 25 | +public class Person { |
| 26 | +
|
| 27 | + /** |
| 28 | + * This contains name. |
| 29 | + */ |
| 30 | + private String name; |
| 31 | +
|
| 32 | + /** |
| 33 | + * This contains age. |
| 34 | + */ |
| 35 | + private int age; |
| 36 | +
|
| 37 | + private Date birthDate; |
| 38 | +
|
| 39 | + private CustomData additionalInfo; |
| 40 | +
|
| 41 | +
|
| 42 | + public String getName() { |
| 43 | + return name; |
| 44 | + } |
| 45 | +
|
| 46 | +
|
| 47 | + public void setName(String name) { |
| 48 | + this.name = name; |
| 49 | + } |
| 50 | +
|
| 51 | +
|
| 52 | + public int getAge() { |
| 53 | + return age; |
| 54 | + } |
| 55 | +
|
| 56 | +
|
| 57 | + public void setAge(int age) { |
| 58 | + this.age = age; |
| 59 | + } |
| 60 | +
|
| 61 | +
|
| 62 | + public Date getBirthDate() { |
| 63 | + return birthDate; |
| 64 | + } |
| 65 | +
|
| 66 | +
|
| 67 | + public void setBirthDate(Date birthDate) { |
| 68 | + this.birthDate = birthDate; |
| 69 | + } |
| 70 | +
|
| 71 | +
|
| 72 | + public CustomData getAdditionalInfo() { |
| 73 | + return additionalInfo; |
| 74 | + } |
| 75 | +
|
| 76 | +
|
| 77 | + public void setAdditionalInfo(CustomData additionalInfo) { |
| 78 | + this.additionalInfo = additionalInfo; |
| 79 | + } |
| 80 | +
|
| 81 | +
|
| 82 | + @Override |
| 83 | + public boolean equals(Object obj) { |
| 84 | + if (this == obj) |
| 85 | + return true; |
| 86 | + if (!(obj instanceof Person)) |
| 87 | + return false; |
| 88 | + Person that = (Person) obj; |
| 89 | + return Objects.equals(getName(), that.getName()) |
| 90 | + && Objects.equals(getAge(), that.getAge()) |
| 91 | + && Objects.equals(getBirthDate(), that.getBirthDate()) |
| 92 | + && Objects.equals(getAdditionalInfo(), that.getAdditionalInfo()); |
| 93 | + } |
| 94 | +
|
| 95 | +
|
| 96 | + @Override |
| 97 | + public int hashCode() { |
| 98 | + return Objects.hash( |
| 99 | + getName(), |
| 100 | + getAge(), |
| 101 | + getBirthDate(), |
| 102 | + getAdditionalInfo() |
| 103 | + ); |
| 104 | + } |
| 105 | +} |
| 106 | +""" |
| 107 | + |
| 108 | +expected_java_class_heartbeat = """\ |
| 109 | +package expected.DataTypes; |
| 110 | +
|
| 111 | +
|
| 112 | +public class Heartbeat { |
| 113 | +} |
| 114 | +""" |
0 commit comments