Skip to content

Commit c112c58

Browse files
committed
automated cleanup
1 parent 2caf39b commit c112c58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+396
-386
lines changed

core/src/androidTest/java/io/snabble/sdk/EAN13Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void testInternalChecksum() {
5656
checkInternalChecksum(3, "2810063024800");
5757
}
5858

59-
private void checkInternalChecksum(int checksum, String code){
59+
private void checkInternalChecksum(int checksum, String code) {
6060
Assert.assertEquals(checksum, EAN13.internalChecksum(code));
6161
}
6262
}

core/src/androidTest/java/io/snabble/sdk/ProductDatabaseTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ public void testMultipleResultsAreDistinct() {
110110
ProductDatabase productDatabase = project.getProductDatabase();
111111
Cursor cursor = productDatabase.searchByCode("5", null);
112112
Set<Product> set = new HashSet<>();
113-
while(cursor.moveToNext()){
113+
while (cursor.moveToNext()) {
114114
Product p = productDatabase.productAtCursor(cursor);
115-
if(set.contains(p)){
115+
if (set.contains(p)) {
116116
assertFalse(true);
117117
}
118118
set.add(p);
@@ -400,4 +400,4 @@ public void testTransmissionCode() throws IOException, Snabble.SnabbleException
400400

401401
Assert.assertEquals(product.getTransmissionCode(product.getScannableCodes()[0]), "00000" + product.getScannableCodes()[0]);
402402
}
403-
}
403+
}

core/src/androidTest/java/io/snabble/sdk/SnabbleSdkTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public MockResponse dispatch(RecordedRequest request) {
8686
.addHeader("Cache-Control", "no-cache")
8787
.setBody("{\"token\":\"\"," +
8888
"\"issuedAt\":" + (System.currentTimeMillis() / 1000) + "," +
89-
"\"expiresAt\":"+ (System.currentTimeMillis() / 1000 + TimeUnit.HOURS.toSeconds(1))
89+
"\"expiresAt\":" + (System.currentTimeMillis() / 1000 + TimeUnit.HOURS.toSeconds(1))
9090
+ "}")
9191
.setResponseCode(200);
9292
}

core/src/main/java/io/snabble/sdk/Checkout.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,15 @@ public void onFailure(Call call, IOException e) {
231231

232232
/**
233233
* Cancels outstanding http calls and sets the checkout to its initial state.
234-
*
234+
* <p>
235235
* Does NOT notify the backend that the checkout was cancelled.
236236
*/
237237
public void reset() {
238238
cancelOutstandingCalls();
239239
notifyStateChanged(State.NONE);
240240
}
241241

242-
private void cancelOutstandingCalls(){
242+
private void cancelOutstandingCalls() {
243243
if (call != null) {
244244
call.cancel();
245245
call = null;
@@ -305,7 +305,7 @@ public void onResponse(Call call, Response response) throws IOException {
305305
String json = IOUtils.toString(inputStream, Charset.forName("UTF-8"));
306306
signedCheckoutInfo = gson.fromJson(json, SignedCheckoutInfo.class);
307307

308-
if(signedCheckoutInfo.checkoutInfo.has("price")
308+
if (signedCheckoutInfo.checkoutInfo.has("price")
309309
&& signedCheckoutInfo.checkoutInfo.get("price").getAsJsonObject().has("price")) {
310310
priceToPay = signedCheckoutInfo.checkoutInfo
311311
.get("price")
@@ -316,7 +316,7 @@ public void onResponse(Call call, Response response) throws IOException {
316316
priceToPay = shoppingCart.getTotalPrice();
317317
}
318318

319-
if(priceToPay != shoppingCart.getTotalPrice()){
319+
if (priceToPay != shoppingCart.getTotalPrice()) {
320320
Logger.w("Warning local price is different from remotely calculated price! (Local: "
321321
+ shoppingCart.getTotalPrice() + ", Remote: " + priceToPay + ")");
322322
}
@@ -532,36 +532,36 @@ private boolean handleProcessResponse(CheckoutProcessResponse checkoutProcessRes
532532
return false;
533533
}
534534

535-
private void approve(){
535+
private void approve() {
536536
Logger.d("Payment approved");
537537
shoppingCart.invalidate();
538538
clearCodes();
539539
notifyStateChanged(State.PAYMENT_APPROVED);
540540
}
541541

542542
public void approveOfflineMethod() {
543-
if(paymentMethod.isOfflineMethod()) {
543+
if (paymentMethod.isOfflineMethod()) {
544544
approve();
545545
}
546546
}
547547

548-
public void setClientAcceptedPaymentMethods(PaymentMethod[] acceptedPaymentMethods){
548+
public void setClientAcceptedPaymentMethods(PaymentMethod[] acceptedPaymentMethods) {
549549
clientAcceptedPaymentMethods = acceptedPaymentMethods;
550550
}
551551

552-
public void addCode(String code){
552+
public void addCode(String code) {
553553
codes.add(code);
554554
}
555555

556-
public void removeCode(String code){
556+
public void removeCode(String code) {
557557
codes.remove(code);
558558
}
559559

560560
public Collection<String> getCodes() {
561561
return Collections.unmodifiableCollection(codes);
562562
}
563563

564-
public void clearCodes(){
564+
public void clearCodes() {
565565
codes.clear();
566566
}
567567

@@ -598,13 +598,14 @@ public PaymentMethod[] getAvailablePaymentMethods() {
598598
JsonArray jsonArray = signedCheckoutInfo.checkoutInfo.getAsJsonArray("availableMethods");
599599
if (jsonArray != null) {
600600
List<PaymentMethod> paymentMethods = gson.fromJson(jsonArray,
601-
new TypeToken<List<PaymentMethod>>(){}.getType());
601+
new TypeToken<List<PaymentMethod>>() {
602+
}.getType());
602603

603-
if(clientAcceptedPaymentMethods != null) {
604+
if (clientAcceptedPaymentMethods != null) {
604605
List<PaymentMethod> result = new ArrayList<>();
605606

606607
for (PaymentMethod clientPaymentMethod : clientAcceptedPaymentMethods) {
607-
if(paymentMethods.contains(clientPaymentMethod)){
608+
if (paymentMethods.contains(clientPaymentMethod)) {
608609
result.add(clientPaymentMethod);
609610
}
610611
}

core/src/main/java/io/snabble/sdk/Events.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public Events(Project project) {
4949
project.getShoppingCart().addListener(new ShoppingCart.SimpleShoppingCartListener() {
5050
@Override
5151
public void onChanged(ShoppingCart list) {
52-
if(cartId != null && !list.getId().equals(cartId)){
52+
if (cartId != null && !list.getId().equals(cartId)) {
5353
PayloadSessionEnd payloadSessionEnd = new PayloadSessionEnd();
5454
payloadSessionEnd.session = cartId;
5555
post(payloadSessionEnd);
@@ -64,7 +64,7 @@ public void onChanged(ShoppingCart list) {
6464
public void onActivityResumed(Activity activity) {
6565
isResumed = true;
6666

67-
if(!hasSentSessionStart) {
67+
if (!hasSentSessionStart) {
6868
updateShop(shop);
6969
}
7070
}
@@ -77,7 +77,7 @@ public void onActivityPaused(Activity activity) {
7777
}
7878

7979
public void updateShop(Shop newShop) {
80-
if(newShop != null){
80+
if (newShop != null) {
8181
cartId = project.getShoppingCart().getId();
8282
shop = newShop;
8383

@@ -95,18 +95,18 @@ public void updateShop(Shop newShop) {
9595
}
9696

9797
private <T extends Payload> void post(final T payload) {
98-
if(!isResumed) {
98+
if (!isResumed) {
9999
Logger.d("Could not send event, app is not active: " + payload.getEventType());
100100
return;
101101
}
102102

103103
String url = project.getEventsUrl();
104-
if(url == null){
104+
if (url == null) {
105105
Logger.e("Could not post event: no events url");
106106
return;
107107
}
108108

109-
if(shop == null) {
109+
if (shop == null) {
110110
return;
111111
}
112112

@@ -132,7 +132,7 @@ public void run() {
132132
okHttpClient.newCall(request).enqueue(new Callback() {
133133
@Override
134134
public void onResponse(Call call, Response response) {
135-
if(response.isSuccessful()) {
135+
if (response.isSuccessful()) {
136136
Logger.d("Successfully posted event: " + payload.getEventType());
137137
} else {
138138
Logger.e("Failed to post event: " + payload.getEventType() + ", code " + response.code());
@@ -148,7 +148,7 @@ public void onFailure(Call call, IOException e) {
148148
}
149149
}, event.type, SystemClock.uptimeMillis() + 2000);
150150

151-
if(event.type == EventType.SESSION_START) {
151+
if (event.type == EventType.SESSION_START) {
152152
hasSentSessionStart = true;
153153
}
154154
}
@@ -182,13 +182,13 @@ private PayloadCart getPayloadCart() {
182182

183183
payloadCart.items[i] = new PayloadCartItem();
184184
payloadCart.items[i].sku = String.valueOf(product.getSku());
185-
payloadCart.items[i].scannedCode = shoppingCart.getScannedCode(i);
185+
payloadCart.items[i].scannedCode = shoppingCart.getScannedCode(i);
186186
payloadCart.items[i].amount = quantity;
187187
payloadCart.items[i].units = shoppingCart.getEmbeddedUnits(i);
188188
payloadCart.items[i].weight = shoppingCart.getEmbeddedWeight(i);
189189
payloadCart.items[i].price = shoppingCart.getEmbeddedPrice(i);
190190

191-
if(product.getType() == Product.Type.UserWeighed){
191+
if (product.getType() == Product.Type.UserWeighed) {
192192
payloadCart.items[i].amount = 1;
193193
payloadCart.items[i].weight = quantity;
194194
}

core/src/main/java/io/snabble/sdk/OkHttpClientFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class OkHttpClientFactory {
1212
static OkHttpClient createOkHttpClient(Application application,
13-
Project project) {
13+
Project project) {
1414
OkHttpClient.Builder builder = new OkHttpClient.Builder();
1515

1616
builder.cache(new Cache(application.getCacheDir(), 10485760)); //10 MB
@@ -36,7 +36,7 @@ public void log(String message) {
3636

3737
builder.addInterceptor(new UserAgentInterceptor(application));
3838

39-
if(config.sslSocketFactory != null && config.x509TrustManager != null) {
39+
if (config.sslSocketFactory != null && config.x509TrustManager != null) {
4040
builder.sslSocketFactory(config.sslSocketFactory, config.x509TrustManager);
4141
}
4242

core/src/main/java/io/snabble/sdk/PaymentMethod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public enum PaymentMethod {
1212

1313
private boolean isOfflineMethod;
1414

15-
PaymentMethod(boolean isOfflineMethod){
15+
PaymentMethod(boolean isOfflineMethod) {
1616
this.isOfflineMethod = isOfflineMethod;
1717
}
1818

core/src/main/java/io/snabble/sdk/Product.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public enum Type {
3434

3535
private int databaseValue;
3636

37-
Type(int databaseValue){
37+
Type(int databaseValue) {
3838
this.databaseValue = databaseValue;
3939
}
4040

41-
public int getDatabaseValue(){
41+
public int getDatabaseValue() {
4242
return databaseValue;
4343
}
4444
}
@@ -64,22 +64,22 @@ public enum SaleRestriction {
6464

6565
private static SaleRestriction[] values = SaleRestriction.values();
6666

67-
SaleRestriction(long dbType, long value){
67+
SaleRestriction(long dbType, long value) {
6868
this.databaseType = dbType;
6969
this.value = value;
7070
}
7171

72-
public long getValue(){
72+
public long getValue() {
7373
return value;
7474
}
7575

7676
public boolean isAgeRestriction() {
7777
return databaseType == 1;
7878
}
7979

80-
public static SaleRestriction fromDatabaseField(long dbType, long value){
81-
for(SaleRestriction sr : values){
82-
if(sr.databaseType == dbType && sr.value == value){
80+
public static SaleRestriction fromDatabaseField(long dbType, long value) {
81+
for (SaleRestriction sr : values) {
82+
if (sr.databaseType == dbType && sr.value == value) {
8383
return sr;
8484
}
8585
}
@@ -128,9 +128,9 @@ public String[] getScannableCodes() {
128128
}
129129

130130
public String getTransmissionCode(String code) {
131-
if(transmissionCodes != null) {
131+
if (transmissionCodes != null) {
132132
String newCode = transmissionCodes.get(code);
133-
if(newCode != null) {
133+
if (newCode != null) {
134134
return newCode;
135135
}
136136
}
@@ -223,11 +223,11 @@ public SaleRestriction getSaleRestriction() {
223223
/**
224224
* @return returns true if this product should not be available for sale anymore.
225225
*/
226-
public boolean getSaleStop(){
226+
public boolean getSaleStop() {
227227
return saleStop;
228228
}
229229

230-
public int getPriceForQuantity(int quantity, RoundingMode roundingMode){
230+
public int getPriceForQuantity(int quantity, RoundingMode roundingMode) {
231231
if (type == Product.Type.UserWeighed || type == Product.Type.PreWeighed) {
232232
BigDecimal pricePerUnit = new BigDecimal(getDiscountedPrice())
233233
.divide(new BigDecimal(1000));
@@ -340,18 +340,18 @@ public Builder setBasePrice(String basePrice) {
340340
return this;
341341
}
342342

343-
public Builder setSaleRestriction(SaleRestriction saleRestriction){
343+
public Builder setSaleRestriction(SaleRestriction saleRestriction) {
344344
product.saleRestriction = saleRestriction;
345345
return this;
346346
}
347347

348-
public Builder setSaleStop(boolean saleStop){
348+
public Builder setSaleStop(boolean saleStop) {
349349
product.saleStop = saleStop;
350350
return this;
351351
}
352352

353-
public Builder addTransmissionCode(String fromCode, String transmissionCode){
354-
if(product.transmissionCodes == null) {
353+
public Builder addTransmissionCode(String fromCode, String transmissionCode) {
354+
if (product.transmissionCodes == null) {
355355
product.transmissionCodes = new HashMap<>();
356356
}
357357

core/src/main/java/io/snabble/sdk/ProductApi.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.google.gson.JsonParseException;
99

1010
import org.apache.commons.io.IOUtils;
11-
import org.apache.commons.lang3.StringUtils;
1211

1312
import java.io.IOException;
1413
import java.io.InputStream;
@@ -382,9 +381,9 @@ private Product toProduct(ApiProduct apiProduct, Product depositProduct, Product
382381
.setSaleRestriction(apiProduct.saleRestriction)
383382
.setSaleStop(apiProduct.saleStop);
384383

385-
if(apiProduct.codes != null) {
384+
if (apiProduct.codes != null) {
386385
for (ApiScannableCode apiScannableCode : apiProduct.codes) {
387-
if(apiScannableCode.code != null && apiScannableCode.transmissionCode != null) {
386+
if (apiScannableCode.code != null && apiScannableCode.transmissionCode != null) {
388387
builder.addTransmissionCode(apiScannableCode.code, apiScannableCode.transmissionCode);
389388
}
390389
}

0 commit comments

Comments
 (0)