Last active
December 22, 2015 00:09
-
-
Save TangKe/6387090 to your computer and use it in GitHub Desktop.
for Hao
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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