| 1 | package pl.zankowski.iextrading4j.client.rest.request.datapoint; | |
| 2 | ||
| 3 | import com.google.common.collect.Maps; | |
| 4 | import pl.zankowski.iextrading4j.client.rest.manager.RestRequest; | |
| 5 | import pl.zankowski.iextrading4j.client.rest.manager.RestRequestBuilder; | |
| 6 | import pl.zankowski.iextrading4j.client.rest.request.IEXCloudV1RestRequest; | |
| 7 | import pl.zankowski.iextrading4j.client.rest.request.IRestRequestBuilder; | |
| 8 | ||
| 9 | import javax.ws.rs.core.GenericType; | |
| 10 | import java.time.LocalDate; | |
| 11 | import java.time.format.DateTimeFormatter; | |
| 12 | import java.util.Map; | |
| 13 | ||
| 14 | public class AbstractTimeSeriesRequestBuilder<R, B extends IRestRequestBuilder<R>> implements IEXCloudV1RestRequest<R> { | |
| 15 | ||
| 16 | public static final DateTimeFormatter IEX_DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd"); | |
| 17 | ||
| 18 | private static final String RANGE_PARAM_NAME = "range"; | |
| 19 | private static final String CALENDAR_PARAM_NAME = "calendar"; | |
| 20 | private static final String LIMIT_PARAM_NAME = "limit"; | |
| 21 | private static final String FROM_PARAM_NAME = "from"; | |
| 22 | private static final String TO_PARAM_NAME = "to"; | |
| 23 | private static final String ON_PARAM_NAME = "on"; | |
| 24 | private static final String LAST_PARAM_NAME = "last"; | |
| 25 | private static final String FIRST_PARAM_NAME = "first"; | |
| 26 | private static final String UPDATED_PARAM_NAME = "updated"; | |
| 27 | private static final String SUBATTRIBUTE_PARAM_NAME = "subattribute"; | |
| 28 | private static final String DATE_FIELD_PARAM_NAME = "dateField"; | |
| 29 | ||
| 30 | private final Map<String, String> queryParameters = Maps.newHashMap(); | |
| 31 | ||
| 32 | private final String id; | |
| 33 | private final GenericType<R> responseType; | |
| 34 | private String key; | |
| 35 | private String subKey; | |
| 36 | ||
| 37 | protected AbstractTimeSeriesRequestBuilder(final String id, final GenericType<R> responseType) { | |
| 38 | this.id = id; | |
| 39 | this.responseType = responseType; | |
| 40 | } | |
| 41 | ||
| 42 | public B withFrom(final LocalDate from) { | |
| 43 | queryParameters.put(FROM_PARAM_NAME, IEX_DATE_FORMATTER.format(from)); | |
| 44 |
1
1. withFrom : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withFrom → KILLED |
return (B) this; |
| 45 | } | |
| 46 | ||
| 47 | public B withTo(final LocalDate to) { | |
| 48 | queryParameters.put(TO_PARAM_NAME, IEX_DATE_FORMATTER.format(to)); | |
| 49 |
1
1. withTo : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withTo → KILLED |
return (B) this; |
| 50 | } | |
| 51 | ||
| 52 | protected B withOn(final LocalDate on) { | |
| 53 | queryParameters.put(ON_PARAM_NAME, IEX_DATE_FORMATTER.format(on)); | |
| 54 |
1
1. withOn : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withOn → KILLED |
return (B) this; |
| 55 | } | |
| 56 | ||
| 57 | public B withLast(final int last) { | |
| 58 | queryParameters.put(LAST_PARAM_NAME, String.valueOf(last)); | |
| 59 |
1
1. withLast : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withLast → KILLED |
return (B) this; |
| 60 | } | |
| 61 | ||
| 62 | public B withFirst(final int first) { | |
| 63 | queryParameters.put(FIRST_PARAM_NAME, String.valueOf(first)); | |
| 64 |
1
1. withFirst : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withFirst → KILLED |
return (B) this; |
| 65 | } | |
| 66 | ||
| 67 | public B withRange(final TimeSeriesRange range) { | |
| 68 | queryParameters.put(RANGE_PARAM_NAME, range.getCode()); | |
| 69 |
1
1. withRange : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withRange → KILLED |
return (B) this; |
| 70 | } | |
| 71 | ||
| 72 | public B withRange(final int number, final TimeSeriesRangeUnit unit) { | |
| 73 | queryParameters.put(RANGE_PARAM_NAME, number + unit.getCode()); | |
| 74 |
1
1. withRange : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withRange → KILLED |
return (B) this; |
| 75 | } | |
| 76 | ||
| 77 | public B withCalendar(final boolean state) { | |
| 78 | queryParameters.put(CALENDAR_PARAM_NAME, String.valueOf(state)); | |
| 79 |
1
1. withCalendar : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withCalendar → KILLED |
return (B) this; |
| 80 | } | |
| 81 | ||
| 82 | protected B withLimit(final int limit) { | |
| 83 | queryParameters.put(LIMIT_PARAM_NAME, String.valueOf(limit)); | |
| 84 |
1
1. withLimit : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withLimit → KILLED |
return (B) this; |
| 85 | } | |
| 86 | ||
| 87 | protected B withUpdated(final boolean state) { | |
| 88 | queryParameters.put(UPDATED_PARAM_NAME, String.valueOf(state)); | |
| 89 |
1
1. withUpdated : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withUpdated → KILLED |
return (B) this; |
| 90 | } | |
| 91 | ||
| 92 | protected B withSubattribute(final String subattribute) { | |
| 93 | queryParameters.put(SUBATTRIBUTE_PARAM_NAME, subattribute); | |
| 94 |
1
1. withSubattribute : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withSubattribute → KILLED |
return (B) this; |
| 95 | } | |
| 96 | ||
| 97 | protected B withSubattribute(final String keyName, final String value) { | |
| 98 | queryParameters.put(SUBATTRIBUTE_PARAM_NAME, keyName + "|" + value); | |
| 99 |
1
1. withSubattribute : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withSubattribute → KILLED |
return (B) this; |
| 100 | } | |
| 101 | ||
| 102 | protected B withDateField(final String dateField) { | |
| 103 | queryParameters.put(DATE_FIELD_PARAM_NAME, dateField); | |
| 104 |
1
1. withDateField : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withDateField → NO_COVERAGE |
return (B) this; |
| 105 | } | |
| 106 | ||
| 107 | protected B withKey(final String key) { | |
| 108 | this.key = key; | |
| 109 |
1
1. withKey : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withKey → KILLED |
return (B) this; |
| 110 | } | |
| 111 | ||
| 112 | protected B withSubKey(final String subKey) { | |
| 113 | this.subKey = subKey; | |
| 114 |
1
1. withSubKey : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::withSubKey → KILLED |
return (B) this; |
| 115 | } | |
| 116 | ||
| 117 | @Override | |
| 118 | public RestRequest<R> build() { | |
| 119 |
1
1. build : negated conditional → KILLED |
if (subKey != null) { |
| 120 |
1
1. build : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::build → KILLED |
return RestRequestBuilder.<R>builder() |
| 121 | .withPath("/time-series/{id}/{key}/{subKey}") | |
| 122 | .addPathParam("id", id) | |
| 123 | .addPathParam("key", key) | |
| 124 | .addPathParam("subKey", subKey).get() | |
| 125 | .withResponse(responseType) | |
| 126 | .addQueryParam(queryParameters) | |
| 127 | .build(); | |
| 128 | } | |
| 129 |
1
1. build : negated conditional → KILLED |
if (key != null) { |
| 130 |
1
1. build : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::build → KILLED |
return RestRequestBuilder.<R>builder() |
| 131 | .withPath("/time-series/{id}/{key}") | |
| 132 | .addPathParam("id", id) | |
| 133 | .addPathParam("key", key).get() | |
| 134 | .withResponse(responseType) | |
| 135 | .addQueryParam(queryParameters) | |
| 136 | .build(); | |
| 137 | } | |
| 138 |
1
1. build : replaced return value with null for pl/zankowski/iextrading4j/client/rest/request/datapoint/AbstractTimeSeriesRequestBuilder::build → NO_COVERAGE |
return RestRequestBuilder.<R>builder() |
| 139 | .withPath("/time-series/{id}") | |
| 140 | .addPathParam("id", id).get() | |
| 141 | .withResponse(responseType) | |
| 142 | .addQueryParam(queryParameters) | |
| 143 | .build(); | |
| 144 | } | |
| 145 | ||
| 146 | } | |
Mutations | ||
| 44 |
1.1 |
|
| 49 |
1.1 |
|
| 54 |
1.1 |
|
| 59 |
1.1 |
|
| 64 |
1.1 |
|
| 69 |
1.1 |
|
| 74 |
1.1 |
|
| 79 |
1.1 |
|
| 84 |
1.1 |
|
| 89 |
1.1 |
|
| 94 |
1.1 |
|
| 99 |
1.1 |
|
| 104 |
1.1 |
|
| 109 |
1.1 |
|
| 114 |
1.1 |
|
| 119 |
1.1 |
|
| 120 |
1.1 |
|
| 129 |
1.1 |
|
| 130 |
1.1 |
|
| 138 |
1.1 |