Skip to content

Commit 449303b

Browse files
committed
refactoring Extractors
1 parent d9712a6 commit 449303b

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/main/java/im/nll/data/extractor/Extractors.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,29 @@ public <T> List<T> asBeanList(Class<T> clazz) {
115115
return entityList;
116116
}
117117

118+
//------------ custom process --------------//
119+
120+
public <T> T asBean(EntityExtractor<T> entityExtractor) {
121+
T entity = entityExtractor.extract(html);
122+
return entity;
123+
}
124+
125+
public <T> List<T> asBeanList(EntityExtractor<T> entityExtractor) {
126+
Validate.notNull(htmlList, "must split first!");
127+
List<T> entityList = Lists.newLinkedList();
128+
for (String input : htmlList) {
129+
T entity = entityExtractor.extract(input);
130+
entityList.add(entity);
131+
}
132+
return entityList;
133+
}
134+
135+
public <T> List<T> asBeanList(EntityListExtractor<T> entityListExtractor) {
136+
return entityListExtractor.extractList(html);
137+
}
138+
//------------ custom process --------------//
139+
140+
118141
//------------ internal --------------//
119142

120143
private <T> T extractBean(String html, Class<T> clazz) {
@@ -166,29 +189,6 @@ private String filter(String name, String result) {
166189
//------------ internal --------------//
167190

168191

169-
//------------ custom process --------------//
170-
171-
public <T> T asBean(EntityExtractor<T> entityExtractor) {
172-
T entity = entityExtractor.extract(html);
173-
return entity;
174-
}
175-
176-
public <T> List<T> asBeanList(EntityExtractor<T> entityExtractor) {
177-
Validate.notNull(htmlList, "must split first!");
178-
List<T> entityList = Lists.newLinkedList();
179-
for (String input : htmlList) {
180-
T entity = entityExtractor.extract(input);
181-
entityList.add(entity);
182-
}
183-
return entityList;
184-
}
185-
186-
public <T> List<T> asBeanList(EntityListExtractor<T> entityListExtractor) {
187-
return entityListExtractor.extractList(html);
188-
}
189-
//------------ custom process --------------//
190-
191-
192192
public static Extractor selector(String query) {
193193
return new SelectorExtractor(query);
194194
}

0 commit comments

Comments
 (0)