DisplayName return a non-empty string to display, representing the identity, based on the non-empty values.
()
| 438 | // DisplayName return a non-empty string to display, representing the |
| 439 | // identity, based on the non-empty values. |
| 440 | func (i *Identity) DisplayName() string { |
| 441 | switch { |
| 442 | case i.Name() == "" && i.Login() != "": |
| 443 | return i.Login() |
| 444 | case i.Name() != "" && i.Login() == "": |
| 445 | return i.Name() |
| 446 | case i.Name() != "" && i.Login() != "": |
| 447 | return fmt.Sprintf("%s (%s)", i.Name(), i.Login()) |
| 448 | } |
| 449 | |
| 450 | panic("invalid person data") |
| 451 | } |
| 452 | |
| 453 | // Email return the last version of the email |
| 454 | func (i *Identity) Email() string { |