(dataSource interface{}, requiredInterfaceName string)
| 363 | } |
| 364 | |
| 365 | func itemsFromReflectModelDataSource(dataSource interface{}, requiredInterfaceName string) (interface{}, error) { |
| 366 | var items interface{} |
| 367 | if rm, ok := dataSource.(reflectModel); ok { |
| 368 | items = rm.Items() |
| 369 | } else { |
| 370 | items = dataSource |
| 371 | } |
| 372 | |
| 373 | if requiredInterfaceName == "ReflectListModel" { |
| 374 | if _, ok := dataSource.([]string); ok { |
| 375 | return items, nil |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | if t := reflect.TypeOf(items); t != nil && |
| 380 | t.Kind() == reflect.Slice && |
| 381 | (t.Elem().Kind() == reflect.Struct || |
| 382 | (t.Elem().Kind() == reflect.Interface || t.Elem().Kind() == reflect.Ptr) && |
| 383 | t.Elem().Elem().Kind() == reflect.Struct) { |
| 384 | |
| 385 | return items, nil |
| 386 | } |
| 387 | |
| 388 | return nil, newError(fmt.Sprintf("dataSource must be a slice of struct or interface or pointer to struct or must implement %s.", requiredInterfaceName)) |
| 389 | } |
| 390 | |
| 391 | func valueFromSlice(dataSource interface{}, itemsValue reflect.Value, member string, index int) interface{} { |
| 392 | if member == "" { |
no test coverage detected
searching dependent graphs…