Dan Anglin
73547c49c6
Add a new Identity type with the required methods so that now the board types (Card, Status and soon Tag) can automatically satisfy the BoltItem interface.
26 lines
380 B
Go
26 lines
380 B
Go
package board
|
|
|
|
type Identity struct {
|
|
ID int
|
|
}
|
|
|
|
// SetID updates the ID value with a valid ID value
|
|
// only if the ID is unset (i.e. < 1).
|
|
func (i *Identity) SetID(id int) error {
|
|
if id < 1 {
|
|
return InvalidIDError{id}
|
|
}
|
|
|
|
if i.ID > 0 {
|
|
return IDAlreadySetError{}
|
|
}
|
|
|
|
i.ID = id
|
|
|
|
return nil
|
|
}
|
|
|
|
// GetID returns the ID value.
|
|
func (i *Identity) GetID() int {
|
|
return i.ID
|
|
}
|