Skip to content

Instantly share code, notes, and snippets.

@TangKe
Last active December 22, 2015 00:09
Show Gist options
  • Save TangKe/6387090 to your computer and use it in GitHub Desktop.
Save TangKe/6387090 to your computer and use it in GitHub Desktop.
for Hao
package com.example.test;
import java.io.Closeable;
import java.io.IOException;
public abstract class Parser<Input, Reader, Result> {
public Result parse(Input input) throws IOException {
if (null == input) {
return null;
}
Result result = doParse(input, makeReader(input));
if (input instanceof Closeable) {
((Closeable) input).close();
}
return result;
}
protected abstract Reader makeReader(Input input);
protected abstract Result doParse(Input input, Reader reader);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment