1
0

improved Stringify

This commit is contained in:
Michael Hoennig
2022-09-30 16:27:18 +02:00
parent 31854bb838
commit d3312c4444
6 changed files with 159 additions and 42 deletions

View File

@ -1,6 +1,8 @@
package net.hostsharing.hsadminng.hs.office.partner;
import lombok.*;
import net.hostsharing.hsadminng.Stringify;
import net.hostsharing.hsadminng.Stringifyable;
import net.hostsharing.hsadminng.hs.office.contact.HsOfficeContactEntity;
import net.hostsharing.hsadminng.hs.office.person.HsOfficePersonEntity;
@ -8,6 +10,8 @@ import javax.persistence.*;
import java.time.LocalDate;
import java.util.UUID;
import static net.hostsharing.hsadminng.Stringify.stringify;
@Entity
@Table(name = "hs_office_partner_rv")
@Getter
@ -15,7 +19,13 @@ import java.util.UUID;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HsOfficePartnerEntity {
public class HsOfficePartnerEntity implements Stringifyable {
private static Stringify<HsOfficePartnerEntity> stringify = stringify(HsOfficePartnerEntity.class, "partner")
.withProp(HsOfficePartnerEntity::getPerson)
.withProp(HsOfficePartnerEntity::getContact)
.withSeparator(": ")
.quotedValues(false);
private @Id UUID uuid;
@ -33,7 +43,13 @@ public class HsOfficePartnerEntity {
private @Column(name = "birthday") LocalDate birthday;
private @Column(name = "dateofdeath") LocalDate dateOfDeath;
public String getDisplayName() {
return "partner(%s, %s)".formatted(person.getDisplayName(), contact.getLabel());
@Override
public String toString() {
return stringify.apply(this);
}
@Override
public String toShortString() {
return person.toShortString();
}
}