-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update java chaincode to be compatible with doc and other implementat…
…ions (#149) * Use numbers without leading zeroes for key Signed-off-by: Stefan Obermeier <scray@stefan-obermeier.de> * Update chaincode to be compatible with doc. E.g. Return key of the queried record Signed-off-by: Stefan Obermeier <scray@stefan-obermeier.de> * Clean up Use always whitespaces to indent the start of the line Remove unnecessary whitespaces Signed-off-by: Stefan Obermeier <scray@stefan-obermeier.de>
- Loading branch information
Showing
3 changed files
with
110 additions
and
43 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...ncode/fabcar/java/src/main/java/org/hyperledger/fabric/samples/fabcar/CarQueryResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.hyperledger.fabric.samples.fabcar; | ||
|
||
import java.util.Objects; | ||
|
||
import org.hyperledger.fabric.contract.annotation.DataType; | ||
import org.hyperledger.fabric.contract.annotation.Property; | ||
|
||
import com.owlike.genson.annotation.JsonProperty; | ||
|
||
/** | ||
* CarQueryResult structure used for handling result of query | ||
* | ||
*/ | ||
@DataType() | ||
public final class CarQueryResult { | ||
@Property() | ||
private final String key; | ||
|
||
@Property() | ||
private final Car record; | ||
|
||
public CarQueryResult(@JsonProperty("Key") final String key, @JsonProperty("Record") final Car record) { | ||
this.key = key; | ||
this.record = record; | ||
} | ||
|
||
public String getKey() { | ||
return key; | ||
} | ||
|
||
public Car getRecord() { | ||
return record; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
|
||
if ((obj == null) || (getClass() != obj.getClass())) { | ||
return false; | ||
} | ||
|
||
CarQueryResult other = (CarQueryResult) obj; | ||
|
||
Boolean recordsAreEquals = this.getRecord().equals(other.getRecord()); | ||
Boolean keysAreEquals = this.getKey().equals(other.getKey()); | ||
|
||
return recordsAreEquals && keysAreEquals; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(this.getKey(), this.getRecord()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "{\"Key\":\"" + key + "\"" + "\"Record\":{\"" + record + "}\"}"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters