mirror of
https://github.com/valitydev/geck.git
synced 2024-11-06 01:35:22 +00:00
BJ-141: TBase handler reuse (#33)
This commit is contained in:
parent
847a2e3e69
commit
49974bdbd3
@ -334,7 +334,19 @@ public class TBaseHandler<R extends TBase> implements StructHandler<R> {
|
||||
|
||||
@Override
|
||||
public R getResult() throws IOException {
|
||||
return result;
|
||||
if (result == null) {
|
||||
throw new BadFormatException("result is null");
|
||||
}
|
||||
|
||||
if (!(stateStack.isEmpty()
|
||||
&& fieldStack.isEmpty()
|
||||
&& elementStack.isEmpty()
|
||||
&& valueMetaDataStack.isEmpty())) {
|
||||
throw new BadFormatException("stack is not empty");
|
||||
}
|
||||
R tBase = result;
|
||||
result = null;
|
||||
return tBase;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -217,6 +217,8 @@ public class TBaseHandlerTest {
|
||||
|
||||
handler.endStruct();
|
||||
|
||||
handler.endStruct();
|
||||
|
||||
handler.getResult();
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user