A String record that may be updated atomically.
| 631 | * A {@code String} record that may be updated atomically. |
| 632 | */ |
| 633 | public final static class String{ |
| 634 | |
| 635 | protected final Store store; |
| 636 | protected final long recid; |
| 637 | |
| 638 | public String(Store store, long recid) { |
| 639 | this.store = store; |
| 640 | this.recid = recid; |
| 641 | } |
| 642 | |
| 643 | |
| 644 | /** |
| 645 | * @return recid under which value is saved |
| 646 | */ |
| 647 | public long getRecid(){ |
| 648 | return recid; |
| 649 | } |
| 650 | |
| 651 | public java.lang.String toString() { |
| 652 | return get(); |
| 653 | } |
| 654 | |
| 655 | /** |
| 656 | * Returns the current value. |
| 657 | * |
| 658 | * @return the current value |
| 659 | */ |
| 660 | public final java.lang.String get() { |
| 661 | return store.get(recid, Serializer.STRING_NOSIZE); |
| 662 | } |
| 663 | |
| 664 | /** |
| 665 | * Atomically sets the value to the given updated value |
| 666 | * if the current value equals the expected value. |
| 667 | * |
| 668 | * @param expect the expected value |
| 669 | * @param update the new value |
| 670 | * @return true if successful. False return indicates that |
| 671 | * the actual value was not equal to the expected value. |
| 672 | */ |
| 673 | public final boolean compareAndSet(java.lang.String expect, java.lang.String update) { |
| 674 | return store.compareAndSwap(recid, expect, update, Serializer.STRING_NOSIZE); |
| 675 | } |
| 676 | |
| 677 | |
| 678 | /** |
| 679 | * Unconditionally sets to the given value. |
| 680 | * |
| 681 | * @param newValue the new value |
| 682 | */ |
| 683 | public final void set(java.lang.String newValue) { |
| 684 | store.update(recid, newValue, Serializer.STRING_NOSIZE); |
| 685 | } |
| 686 | |
| 687 | |
| 688 | /** |
| 689 | * Atomically sets to the given value and returns the previous value. |
| 690 | * |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…