1313import com .mashape .unirest .request .GetRequest ;
1414import com .sybit .airtable .exception .AirtableException ;
1515import com .sybit .airtable .exception .HttpResponseExceptionHandler ;
16- import com .sybit .airtable .vo .Attachment ;
17- import com .sybit .airtable .vo .Delete ;
18- import com .sybit .airtable .vo .PostRecord ;
19- import com .sybit .airtable .vo .RecordItem ;
20- import com .sybit .airtable .vo .Records ;
16+ import com .sybit .airtable .vo .*;
2117import org .apache .commons .beanutils .BeanUtils ;
18+ import org .apache .commons .beanutils .BeanUtilsBean ;
2219import org .apache .commons .beanutils .PropertyUtils ;
2320import org .apache .http .client .HttpResponseException ;
2421import org .slf4j .Logger ;
2724import java .lang .reflect .Field ;
2825import java .lang .reflect .InvocationTargetException ;
2926import java .util .ArrayList ;
30-
3127import java .util .List ;
3228import java .util .Map ;
3329
34- import org .apache .commons .beanutils .BeanUtilsBean ;
35-
3630/**
3731 * Representation Class of Airtable Tables.
3832 *
@@ -49,12 +43,15 @@ public class Table<T> {
4943
5044 /**
5145 *
52- * @param name
53- * @param type
46+ * @param name name of table.
47+ * @param type class to represent table row
5448 */
5549 public Table (String name , Class <T > type ) {
56- this .type = type ;
50+ assert name != null : "name was null" ;
51+ assert type != null : "type was null" ;
52+
5753 this .name = name ;
54+ this .type = type ;
5855 }
5956
6057 /**
@@ -78,10 +75,9 @@ public void setParent(Base parent) {
7875 }
7976
8077 /**
81- *
82- * If no Parameter ser all querys to null.
78+ * Select all rows of table.
8379 *
84- * @return
80+ * @return List of all items.
8581 * @throws AirtableException
8682 */
8783 public List <T > select () throws AirtableException , HttpResponseException {
@@ -122,8 +118,8 @@ public Integer getPageSize() {
122118 /**
123119 * Select List of data of table with defined Query Parameters.
124120 *
125- * @param query
126- * @return
121+ * @param query defined query
122+ * @return list of table items
127123 * @throws AirtableException
128124 */
129125 @ SuppressWarnings ("WeakerAccess" )
@@ -311,10 +307,10 @@ public Integer getPageSize() {
311307 }
312308
313309 /**
314- * select only Table data with defined Fields
315- *
316- * @param fields
317- * @return
310+ * Select only Table data with defined fields.
311+ *
312+ * @param fields array of requested fields.
313+ * @return list of item using only requested fields.
318314 * @throws AirtableException
319315 * @throws HttpResponseException
320316 */
@@ -385,7 +381,7 @@ private List<T> getList(HttpResponse<Records> response) {
385381 */
386382 public T find (String id ) throws AirtableException {
387383
388- RecordItem body = null ;
384+ RecordItem body ;
389385
390386 HttpResponse <RecordItem > response ;
391387 try {
@@ -402,15 +398,14 @@ public T find(String id) throws AirtableException {
402398 body = response .getBody ();
403399 } else {
404400 HttpResponseExceptionHandler .onResponse (response );
401+ body = null ;
405402 }
406403
407404 try {
408405 return transform (body , this .type .newInstance () );
409406 } catch (InvocationTargetException | IllegalAccessException | InstantiationException e ) {
410- LOG . error ( e . getMessage (), e );
407+ throw new AirtableException ( e );
411408 }
412-
413- return null ;
414409 }
415410
416411 /**
0 commit comments