Simplify SetTableName pattern (#214)

This commit is contained in:
Michael Gaffney authored and GitHub committed 2020-07-23 17:58:41 -04:00
1 parent f47046f158
commit e03a0ff9d7
10 files changed
+19 -109

No files matched your search

+3 -13
View File
@@ -14,12 +14,7 @@ func (s *AuthToken) TableName() string {
// SetTableName sets the table name. If the caller attempts to
// set the name to "" the name will be reset to the default name.
func (s *AuthToken) SetTableName(n string) {
switch n {
case "":
s.tableName = defaultAuthTokenTableName
default:
s.tableName = n
}
s.tableName = n
}
// TableName returns the table name for the auth token.
@@ -33,10 +28,5 @@ func (s *writableAuthToken) TableName() string {
// SetTableName sets the table name. If the caller attempts to
// set the name to "" the name will be reset to the default name.
func (s *writableAuthToken) SetTableName(n string) {
switch n {
case "":
s.tableName = defaultWritableAuthTokenTableName
default:
s.tableName = n
}
}
s.tableName = n
}
+3 -18
View File
@@ -84,12 +84,7 @@ func (c *TestCar) TableName() string {
return defaultCarTableName
}
func (c *TestCar) SetTableName(name string) {
switch name {
case "":
c.table = defaultCarTableName
default:
c.table = name
}
c.table = name
}
type TestRental struct {
@@ -116,12 +111,7 @@ func (r *TestRental) TableName() string {
return defaultRentalTableName
}
func (r *TestRental) SetTableName(name string) {
switch name {
case "":
r.table = defaultRentalTableName
default:
r.table = name
}
r.table = name
}
type TestScooter struct {
@@ -155,12 +145,7 @@ func (t *TestScooter) TableName() string {
}
func (t *TestScooter) SetTableName(name string) {
switch name {
case "":
t.table = defaultScooterTableName
default:
t.table = name
}
t.table = name
}
type Cloner interface {
+4 -24
View File
@@ -18,12 +18,7 @@ func (c *HostCatalog) TableName() string {
// SetTableName sets the table name. If the caller attempts to
// set the name to "" the name will be reset to the default name.
func (c *HostCatalog) SetTableName(n string) {
switch n {
case "":
c.tableName = defaultHostCatalogTableName
default:
c.tableName = n
}
c.tableName = n
}
// TableName returns the table name for the host.
@@ -37,12 +32,7 @@ func (h *Host) TableName() string {
// SetTableName sets the table name. If the caller attempts to
// set the name to "" the name will be reset to the default name.
func (h *Host) SetTableName(n string) {
switch n {
case "":
h.tableName = defaultHostTableName
default:
h.tableName = n
}
h.tableName = n
}
// TableName returns the table name for the host set.
@@ -56,12 +46,7 @@ func (s *HostSet) TableName() string {
// SetTableName sets the table name. If the caller attempts to
// set the name to "" the name will be reset to the default name.
func (s *HostSet) SetTableName(n string) {
switch n {
case "":
s.tableName = defaultHostSetTableName
default:
s.tableName = n
}
s.tableName = n
}
// TableName returns the table name for the host set.
@@ -75,10 +60,5 @@ func (m *HostSetMember) TableName() string {
// SetTableName sets the table name. If the caller attempts to
// set the name to "" the name will be reset to the default name.
func (m *HostSetMember) SetTableName(n string) {
switch n {
case "":
m.tableName = defaultHostSetMemberTableName
default:
m.tableName = n
}
m.tableName = n
}
+1 -6
View File
@@ -72,10 +72,5 @@ func (a *AuthAccount) TableName() string {
// interface. If the caller attempts to set the name to "" the name will be
// reset to the default name.
func (a *AuthAccount) SetTableName(n string) {
switch n {
case "":
a.tableName = defaultAuthAccountTableName
default:
a.tableName = n
}
a.tableName = n
}
+1 -6
View File
@@ -99,10 +99,5 @@ func (g *Group) TableName() string {
// interface. If the caller attempts to set the name to "" the name will be
// reset to the default name.
func (g *Group) SetTableName(n string) {
switch n {
case "":
g.tableName = defaultGroupTableName
default:
g.tableName = n
}
g.tableName = n
}
+1 -6
View File
@@ -107,10 +107,5 @@ func (r *Role) TableName() string {
// interface. If the caller attempts to set the name to "" the name will be
// reset to the default name.
func (r *Role) SetTableName(n string) {
switch n {
case "":
r.tableName = defaultRoleTableName
default:
r.tableName = n
}
r.tableName = n
}
+1 -6
View File
@@ -102,10 +102,5 @@ func (g *RoleGrant) TableName() string {
// interface. If the caller attempts to set the name to "" the name will be
// reset to the default name.
func (g *RoleGrant) SetTableName(n string) {
switch n {
case "":
g.tableName = defaultRoleGrantTable
default:
g.tableName = n
}
g.tableName = n
}
+1 -6
View File
@@ -201,10 +201,5 @@ func (s *Scope) TableName() string {
// interface. If the caller attempts to set the name to "" the name will be
// reset to the default name.
func (s *Scope) SetTableName(n string) {
switch n {
case "":
s.tableName = defaultScopeTableName
default:
s.tableName = n
}
s.tableName = n
}
+1 -6
View File
@@ -100,10 +100,5 @@ func (u *User) TableName() string {
// interface. If the caller attempts to set the name to "" the name will be
// reset to the default name.
func (u *User) SetTableName(n string) {
switch n {
case "":
u.tableName = defaultUserTableName
default:
u.tableName = n
}
u.tableName = n
}
+3 -18
View File
@@ -36,12 +36,7 @@ func (u *TestUser) TableName() string {
// ReplayableMessage. If the caller attempts to set the name to "" the name will be
// reset to the default name.
func (u *TestUser) SetTableName(n string) {
switch n {
case "":
u.Table = defaultTestUserTableName
default:
u.Table = n
}
u.Table = n
}
// TableName overrides the table name for TestCar
@@ -54,12 +49,7 @@ func (c *TestCar) TableName() string {
// SetTableName allows the table name to be overridden and makes a TestCar a ReplayableMessage
func (c *TestCar) SetTableName(n string) {
switch n {
case "":
c.Table = defaultTestCarTableName
default:
c.Table = n
}
c.Table = n
}
// TableName overrids the table name for TestRental
@@ -72,10 +62,5 @@ func (r *TestRental) TableName() string {
// SetTableName allows the table name to be overridden and makes a TestRental a ReplayableMessage
func (r *TestRental) SetTableName(n string) {
switch n {
case "":
r.Table = defaultTestRentalTableName
default:
r.Table = n
}
r.Table = n
}