| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package datastore | 5 package datastore |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "encoding/base64" | 9 "encoding/base64" |
| 10 "errors" | 10 "errors" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 329 |
| 330 switch t { | 330 switch t { |
| 331 case typeOfKey: | 331 case typeOfKey: |
| 332 if v.IsNil() { | 332 if v.IsNil() { |
| 333 return nil | 333 return nil |
| 334 } | 334 } |
| 335 } | 335 } |
| 336 return o | 336 return o |
| 337 } | 337 } |
| 338 | 338 |
| 339 func (p Property) String() string { |
| 340 switch p.propType { |
| 341 case PTString, PTBlobKey: |
| 342 return fmt.Sprintf("%s(%q)", p.propType, p.Value()) |
| 343 case PTBytes: |
| 344 return fmt.Sprintf("%s(%#x)", p.propType, p.Value()) |
| 345 default: |
| 346 return fmt.Sprintf("%s(%v)", p.propType, p.Value()) |
| 347 } |
| 348 } |
| 349 |
| 339 // Value returns the current value held by this property. It's guaranteed to | 350 // Value returns the current value held by this property. It's guaranteed to |
| 340 // be a valid value type (i.e. `p.SetValue(p.Value(), true)` will never return | 351 // be a valid value type (i.e. `p.SetValue(p.Value(), true)` will never return |
| 341 // an error). | 352 // an error). |
| 342 func (p *Property) Value() interface{} { | 353 func (p *Property) Value() interface{} { |
| 343 switch p.propType { | 354 switch p.propType { |
| 344 case PTBytes: | 355 case PTBytes: |
| 345 return p.value.(byteSequence).bytes() | 356 return p.value.(byteSequence).bytes() |
| 346 case PTString: | 357 case PTString: |
| 347 return p.value.(byteSequence).string() | 358 return p.value.(byteSequence).string() |
| 348 case PTBlobKey: | 359 case PTBlobKey: |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 if string(s) == string(t) { | 993 if string(s) == string(t) { |
| 983 return 0, true | 994 return 0, true |
| 984 } | 995 } |
| 985 if string(s) < string(t) { | 996 if string(s) < string(t) { |
| 986 return -1, true | 997 return -1, true |
| 987 } | 998 } |
| 988 return 1, true | 999 return 1, true |
| 989 } | 1000 } |
| 990 return 0, false | 1001 return 0, false |
| 991 } | 1002 } |
| OLD | NEW |