Skip to content

Commit 9d87590

Browse files
committed
Revert "Use lombok where sensible"
This reverts commit 7c70945.
1 parent 4977e49 commit 9d87590

30 files changed

+260
-31
lines changed

smart-contract/hyperledger-fabric/v2/java/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ plugins {
1818
application
1919
id("com.github.johnrengelman.shadow") version "7.1.2"
2020
id("com.diffplug.spotless") version "6.19.0"
21-
id("io.freefair.lombok") version "8.6"
2221
}
2322

2423
// java { toolchain { languageVersion.set(JavaLanguageVersion.of(17)) } }
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* SPDX-License-Identifier: Apache-2.0 */
22
package hu.bme.mit.ftsrg.chaincode.tpcc.api;
33

4-
import lombok.experimental.StandardException;
4+
public final class NotFoundException extends Exception {
55

6-
@StandardException
7-
public final class NotFoundException extends Exception {}
6+
NotFoundException(String message) {
7+
super(message);
8+
}
9+
}

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCBusinessAPI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import hu.bme.mit.ftsrg.chaincode.tpcc.data.extra.*;
99
import hu.bme.mit.ftsrg.chaincode.tpcc.data.input.*;
1010
import hu.bme.mit.ftsrg.chaincode.tpcc.data.output.*;
11+
import hu.bme.mit.ftsrg.chaincode.tpcc.middleware.TPCCContext;
1112
import hu.bme.mit.ftsrg.chaincode.tpcc.util.JSON;
1213
import hu.bme.mit.ftsrg.hypernate.Registry;
1314
import hu.bme.mit.ftsrg.hypernate.context.ContextWithRegistry;

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/api/TPCCContractAPI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import hu.bme.mit.ftsrg.chaincode.MethodLogger;
77
import hu.bme.mit.ftsrg.chaincode.tpcc.data.entity.*;
88
import hu.bme.mit.ftsrg.chaincode.tpcc.data.input.*;
9+
import hu.bme.mit.ftsrg.chaincode.tpcc.middleware.TPCCContext;
910
import hu.bme.mit.ftsrg.chaincode.tpcc.util.JSON;
1011
import hu.bme.mit.ftsrg.hypernate.entity.EntityExistsException;
1112
import hu.bme.mit.ftsrg.hypernate.entity.EntityNotFoundException;

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Customer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import org.hyperledger.fabric.contract.annotation.Property;
99

1010
/** Essentially, the CUSTOMER table. */
11-
@DataType
1211
@EqualsAndHashCode
13-
public final class Customer implements Entity {
12+
@DataType()
13+
public class Customer implements Entity {
1414

1515
/** The customer ID. Primary key. */
1616
@KeyPart

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/District.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import org.hyperledger.fabric.contract.annotation.Property;
99

1010
/** Essentially, the DISTRICT table. */
11-
@DataType
1211
@EqualsAndHashCode
12+
@DataType()
1313
public final class District implements Entity {
1414

1515
/** The district ID. Primary key. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/History.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import org.hyperledger.fabric.contract.annotation.Property;
99

1010
/** Essentially, the HISTORY table. */
11-
@DataType
1211
@EqualsAndHashCode
12+
@DataType
1313
public final class History implements Entity {
1414

1515
/** The customer ID. Primary key. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Item.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import org.hyperledger.fabric.contract.annotation.Property;
99

1010
/** Essentially, the ITEM table. */
11-
@DataType
1211
@EqualsAndHashCode
12+
@DataType
1313
public final class Item implements Entity {
1414

1515
/** The ID of the item. Primary key. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/NewOrder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import org.hyperledger.fabric.contract.annotation.Property;
99

1010
/** Essentially, the NEW-ORDER table. */
11-
@DataType
1211
@EqualsAndHashCode
12+
@DataType
1313
public final class NewOrder implements Entity {
1414

1515
/** The order ID. Primary key. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Order.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import org.hyperledger.fabric.contract.annotation.Property;
99

1010
/** Essentially, the ORDER table. */
11-
@DataType
1211
@EqualsAndHashCode
12+
@DataType
1313
public final class Order implements Entity {
1414

1515
/** The order ID. Primary key. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/OrderLine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import org.hyperledger.fabric.contract.annotation.Property;
99

1010
/** Essentially, the ORDER-LINE table. */
11-
@DataType
1211
@EqualsAndHashCode
12+
@DataType
1313
public final class OrderLine implements Entity {
1414

1515
/** The order ID associated with the order line. Primary key. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Stock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import org.hyperledger.fabric.contract.annotation.Property;
99

1010
/** Essentially, the STOCK table. */
11-
@DataType
1211
@EqualsAndHashCode
12+
@DataType
1313
public final class Stock implements Entity {
1414

1515
/** The ID of the item associated with the stock. Primary key. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/entity/Warehouse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import org.hyperledger.fabric.contract.annotation.Property;
99

1010
/** Essentially, the WAREHOUSE table. */
11-
@DataType
1211
@EqualsAndHashCode
12+
@DataType
1313
public class Warehouse implements Entity {
1414

1515
/** The warehouse ID. Primary key. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/DeliveredOrder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import org.hyperledger.fabric.contract.annotation.Property;
88

99
/** Class to encapsulate the <code>delivered</code> field's data of a {@link DeliveryOutput}. */
10-
@DataType
1110
@EqualsAndHashCode
11+
@DataType
1212
public final class DeliveredOrder {
1313

1414
@Property(schema = {"minimum", "0"})

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/ItemsData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import org.hyperledger.fabric.contract.annotation.Property;
88

99
/** Class to encapsulate the <code>items</code> field's data of a {@link NewOrderOutput}. */
10-
@DataType
1110
@EqualsAndHashCode
11+
@DataType
1212
public final class ItemsData {
1313

1414
@Property(schema = {"minimum", "0"})

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/extra/OrderLineData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
/**
1111
* Class to encapsulate the <code>order_lines</code> field's data of a {@link OrderStatusOutput}.
1212
*/
13-
@DataType
1413
@EqualsAndHashCode
14+
@DataType
1515
public final class OrderLineData {
1616

1717
@Property(schema = {"minimum", "0"})

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/DeliveryInput.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/* SPDX-License-Identifier: Apache-2.0 */
22
package hu.bme.mit.ftsrg.chaincode.tpcc.data.input;
33

4+
import hu.bme.mit.ftsrg.chaincode.tpcc.middleware.TPCCContext;
45
import lombok.EqualsAndHashCode;
56
import org.hyperledger.fabric.contract.annotation.DataType;
67
import org.hyperledger.fabric.contract.annotation.Property;
78

8-
@DataType
99
@EqualsAndHashCode
10+
@DataType
1011
public final class DeliveryInput {
1112

1213
/** The warehouse ID. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/NewOrderInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import org.hyperledger.fabric.contract.annotation.DataType;
66
import org.hyperledger.fabric.contract.annotation.Property;
77

8-
@DataType
98
@EqualsAndHashCode
9+
@DataType
1010
public final class NewOrderInput {
1111

1212
/** The warehouse ID. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/OrderStatusInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import org.hyperledger.fabric.contract.annotation.DataType;
66
import org.hyperledger.fabric.contract.annotation.Property;
77

8-
@DataType
98
@EqualsAndHashCode
9+
@DataType
1010
public final class OrderStatusInput {
1111

1212
/** The warehouse ID. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/PaymentInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import org.hyperledger.fabric.contract.annotation.DataType;
66
import org.hyperledger.fabric.contract.annotation.Property;
77

8-
@DataType
98
@EqualsAndHashCode
9+
@DataType
1010
public final class PaymentInput {
1111

1212
/** The warehouse ID. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/input/StockLevelInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import org.hyperledger.fabric.contract.annotation.DataType;
66
import org.hyperledger.fabric.contract.annotation.Property;
77

8-
@DataType
98
@EqualsAndHashCode
9+
@DataType
1010
public final class StockLevelInput {
1111

1212
/** The warehouse ID. */

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/DeliveryOutput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import org.hyperledger.fabric.contract.annotation.DataType;
88
import org.hyperledger.fabric.contract.annotation.Property;
99

10-
@DataType
1110
@EqualsAndHashCode
11+
@DataType
1212
public final class DeliveryOutput {
1313

1414
@Property(schema = {"minimum", "0"})

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/NewOrderOutput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import org.hyperledger.fabric.contract.annotation.DataType;
1212
import org.hyperledger.fabric.contract.annotation.Property;
1313

14-
@DataType
1514
@EqualsAndHashCode
15+
@DataType
1616
public final class NewOrderOutput {
1717

1818
@Property(schema = {"minimum", "0"})

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/OrderStatusOutput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.hyperledger.fabric.contract.annotation.DataType;
1010
import org.hyperledger.fabric.contract.annotation.Property;
1111

12-
@DataType
1312
@EqualsAndHashCode
13+
@DataType
1414
public final class OrderStatusOutput {
1515

1616
@Property(schema = {"minimum", "0"})

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/PaymentOutput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.hyperledger.fabric.contract.annotation.DataType;
1010
import org.hyperledger.fabric.contract.annotation.Property;
1111

12-
@DataType
1312
@EqualsAndHashCode
13+
@DataType
1414
public final class PaymentOutput {
1515

1616
@Property(schema = {"minimum", "0"})

smart-contract/hyperledger-fabric/v2/java/src/main/java/hu/bme/mit/ftsrg/chaincode/tpcc/data/output/StockLevelOutput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import org.hyperledger.fabric.contract.annotation.DataType;
77
import org.hyperledger.fabric.contract.annotation.Property;
88

9-
@DataType
109
@EqualsAndHashCode
10+
@DataType
1111
public final class StockLevelOutput {
1212

1313
@Property(schema = {"minimum", "0"})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
package hu.bme.mit.ftsrg.chaincode.tpcc.middleware;
3+
4+
import hu.bme.mit.ftsrg.hypernate.middleware.ChaincodeStubMiddlewareBase;
5+
import java.util.Arrays;
6+
import org.hyperledger.fabric.shim.ChaincodeStub;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
import org.slf4j.event.Level;
10+
11+
/**
12+
* Stub middleware that simply logs all {@link ChaincodeStub#getState(String)}, {@link
13+
* ChaincodeStub#putState(String, byte[])}, and {@link ChaincodeStub#delState(String)} calls.
14+
*
15+
* @see ChaincodeStubMiddlewareBase
16+
*/
17+
public class LoggingStubMiddleware extends ChaincodeStubMiddlewareBase {
18+
19+
private static final Logger logger = LoggerFactory.getLogger(LoggingStubMiddleware.class);
20+
private final Level logLevel;
21+
22+
public LoggingStubMiddleware(final ChaincodeStub next) {
23+
this(next, Level.INFO);
24+
}
25+
26+
public LoggingStubMiddleware(final ChaincodeStub next, final Level logLevel) {
27+
super(next);
28+
this.logLevel = logLevel;
29+
}
30+
31+
@Override
32+
public byte[] getState(final String key) {
33+
logger.atLevel(this.logLevel).log("Getting state for key '{}'", key);
34+
final byte[] value = this.nextLayer.getState(key);
35+
logger
36+
.atLevel(this.logLevel)
37+
.log("Got state for key '{}'; value = '{}'", key, Arrays.toString(value));
38+
return value;
39+
}
40+
41+
@Override
42+
public void putState(final String key, final byte[] value) {
43+
logger
44+
.atLevel(this.logLevel)
45+
.log("Setting state for key '{}' to have value '{}'", key, Arrays.toString(value));
46+
this.nextLayer.putState(key, value);
47+
logger.atLevel(this.logLevel).log("Done setting state for key '{}'", key);
48+
}
49+
50+
@Override
51+
public void delState(final String key) {
52+
logger.atLevel(this.logLevel).log("Deleting state for key '{}'", key);
53+
this.nextLayer.delState(key);
54+
logger.atLevel(this.logLevel).log("Done deleting state for key '{}'", key);
55+
}
56+
}
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
/* SPDX-License-Identifier: Apache-2.0 */
2-
package hu.bme.mit.ftsrg.chaincode.tpcc.api;
2+
package hu.bme.mit.ftsrg.chaincode.tpcc.middleware;
33

44
import hu.bme.mit.ftsrg.hypernate.context.ContextWithRegistry;
55
import java.util.ArrayDeque;
66
import java.util.ArrayList;
77
import java.util.Deque;
88
import java.util.List;
9-
10-
import hu.bme.mit.ftsrg.hypernate.middleware.LoggingStubMiddleware;
11-
import hu.bme.mit.ftsrg.hypernate.middleware.WriteBackCachedChaincodeStubMiddleware;
129
import org.hyperledger.fabric.shim.ChaincodeStub;
1310

1411
/** Context specialized for the TPC-C chaincode implementation. */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* SPDX-License-Identifier: Apache-2.0 */
2+
package hu.bme.mit.ftsrg.chaincode.tpcc.middleware;
3+
4+
import hu.bme.mit.ftsrg.hypernate.middleware.ChaincodeStubMiddlewareBase;
5+
import org.hyperledger.fabric.shim.ChaincodeStub;
6+
7+
/**
8+
* Stub middleware that only sends {@link ChaincodeStub#putState(String, byte[])} calls once the
9+
* transaction is finished.
10+
*
11+
* @see ChaincodeStubMiddlewareBase
12+
*/
13+
public final class UpdateThrottledChaincodeStubMiddleware extends ChaincodeStubMiddlewareBase {
14+
15+
public UpdateThrottledChaincodeStubMiddleware(ChaincodeStub nextLayer) {
16+
super(nextLayer);
17+
}
18+
19+
/* TODO implement ? */
20+
}

0 commit comments

Comments
 (0)