Mercurial > hg > Members > tatsuki > bench > jungle-core
comparison src/main/java/jp/ac/u_ryukyu/ie/cr/shoshi/jungle/transaction/DefaultJungleTreeEditor.java @ 86:fb1dc448ac8c
delete <T extends TreeNode>
author | one |
---|---|
date | Wed, 03 Sep 2014 23:44:23 +0900 |
parents | a4e2f1d45fdc |
children | 4c6b915302a8 14ce7a0dedca |
comparison
equal
deleted
inserted
replaced
85:22bba77e09a7 | 86:fb1dc448ac8c |
---|---|
21 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; | 21 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.DefaultEither; |
22 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; | 22 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either; |
23 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; | 23 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error; |
24 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.IterableConverter; | 24 import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.IterableConverter; |
25 | 25 |
26 public class DefaultJungleTreeEditor<T extends TreeNode> implements JungleTreeEditor | 26 public class DefaultJungleTreeEditor implements JungleTreeEditor |
27 { | 27 { |
28 private final TransactionManager<T> txManager; | 28 private final TransactionManager txManager; |
29 private final TreeNode root; | 29 private final TreeNode root; |
30 private final TreeEditor editor; | 30 private final TreeEditor editor; |
31 private final TreeOperationLog log; | 31 private final TreeOperationLog log; |
32 | 32 |
33 public DefaultJungleTreeEditor(TreeNode _root,TransactionManager<T> _txManager,TreeEditor _editor) | 33 public DefaultJungleTreeEditor(TreeNode _root,TransactionManager _txManager,TreeEditor _editor) |
34 { | 34 { |
35 this(_root,_txManager,_editor,new DefaultTreeOperationLog()); | 35 this(_root,_txManager,_editor,new DefaultTreeOperationLog()); |
36 } | 36 } |
37 | 37 |
38 public DefaultJungleTreeEditor(TreeNode newNode,TransactionManager<T> _txManager,TreeEditor _editor,TreeOperationLog _log) | 38 public DefaultJungleTreeEditor(TreeNode newNode,TransactionManager _txManager,TreeEditor _editor,TreeOperationLog _log) |
39 { | 39 { |
40 root = newNode; | 40 root = newNode; |
41 txManager = _txManager; | 41 txManager = _txManager; |
42 editor = _editor; | 42 editor = _editor; |
43 log = _log; | 43 log = _log; |
63 | 63 |
64 Iterable<TreeOperation> iterable = new IterableConverter<TreeOperation,NodeOperation>(newLog,converter); | 64 Iterable<TreeOperation> iterable = new IterableConverter<TreeOperation,NodeOperation>(newLog,converter); |
65 DefaultTreeOperationLog treeOperationLog = new DefaultTreeOperationLog(iterable,newLog.length()); | 65 DefaultTreeOperationLog treeOperationLog = new DefaultTreeOperationLog(iterable,newLog.length()); |
66 TreeOperationLog newTreeOpLog = log.append(treeOperationLog); | 66 TreeOperationLog newTreeOpLog = log.append(treeOperationLog); |
67 | 67 |
68 JungleTreeEditor newEditor = new DefaultJungleTreeEditor<T>(newNode,txManager,editor,newTreeOpLog); | 68 JungleTreeEditor newEditor = new DefaultJungleTreeEditor(newNode,txManager,editor,newTreeOpLog); |
69 return DefaultEither.newB(newEditor); | 69 return DefaultEither.newB(newEditor); |
70 } | 70 } |
71 | 71 |
72 @Override | 72 @Override |
73 public Either<Error,JungleTreeEditor> addNewChildAt(NodePath _path, int _pos) | 73 public Either<Error,JungleTreeEditor> addNewChildAt(NodePath _path, int _pos) |
104 } | 104 } |
105 | 105 |
106 @Override | 106 @Override |
107 public Either<Error,JungleTreeEditor> success() | 107 public Either<Error,JungleTreeEditor> success() |
108 { | 108 { |
109 Either<Error,TransactionManager<T>> either = txManager.commit(root,log); | 109 Either<Error,TransactionManager> either = txManager.commit(root,log); |
110 if(either.isA()){ | 110 if(either.isA()){ |
111 return DefaultEither.newA(either.a()); | 111 return DefaultEither.newA(either.a()); |
112 } | 112 } |
113 | 113 |
114 TransactionManager<T> newTxManager = either.b(); | 114 TransactionManager newTxManager = either.b(); |
115 JungleTreeEditor newTreeEditor = new DefaultJungleTreeEditor<T>(root,newTxManager,editor); | 115 JungleTreeEditor newTreeEditor = new DefaultJungleTreeEditor(root,newTxManager,editor); |
116 | 116 |
117 return DefaultEither.newB(newTreeEditor); | 117 return DefaultEither.newB(newTreeEditor); |
118 } | 118 } |
119 | 119 |
120 @Override | 120 @Override |