Skip to content

Commit 04b2b0e

Browse files
authored
Data object support for machine codes (#15)
* Start on machine code methods * Finish machine code methods * Update Data.java * Fix tests * Update Data.java * Update javadoc
1 parent dddfb14 commit 04b2b0e

15 files changed

+518
-9
lines changed

src/main/java/io/cryptolens/methods/Data.java

Lines changed: 222 additions & 6 deletions
Large diffs are not rendered by default.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.cryptolens.models;
2+
3+
public class AddDataObjectToMachineCodeModel extends ProductKeyMachineCodeModel {
4+
5+
/**
6+
* The name of the data object. Max 10 characters.
7+
*/
8+
public String Name;
9+
/**
10+
* An int value (int32) to store.
11+
*/
12+
public int IntValue;
13+
/**
14+
* A string value (text) to store. Max 10000 characters.
15+
*/
16+
public String StringValue;
17+
18+
public AddDataObjectToMachineCodeModel(int productId, String key, String machineCode, String name, int intValue, String stringValue) {
19+
Name = name;
20+
IntValue = intValue;
21+
StringValue = stringValue;
22+
this.ProductId = productId;
23+
this.Key = key;
24+
this.MachineCode = machineCode;
25+
}
26+
}

src/main/java/io/cryptolens/models/DecrementIntValueToKeyModel.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
11
package io.cryptolens.models;
22

33
public class DecrementIntValueToKeyModel extends ProductAndKeyModel {
4+
5+
/**
6+
* The unique object id for the data object.
7+
*/
48
public long Id;
9+
10+
/**
11+
* The constant int value that should be subtracted to the current IntValue of the data object. For example,
12+
* if this value is set to 5 and the old IntValue is 11, then the new IntValue will be the old one minus 5, i.e. 6.
13+
* Note, if you would set this value to -5 instead, the same result would be achieved.
14+
*/
515
public int IntValue;
16+
17+
/**
18+
* If set to true, it will be possible to specify a lower bound. For example, if you set the Bound parameter
19+
* (below) to 0, you will be able to decrement the int value until you reach zero (inclusive).
20+
* Once the lower bound is reached, an error will be thrown.
21+
*/
622
public boolean EnableBound;
23+
24+
/**
25+
* This is the lower bound that will be enforced on the decrement operation.
26+
* It will only be enforced if EnableBound is set to true. Please read the description above.
27+
*/
728
public int Bound;
829

930
public DecrementIntValueToKeyModel(int productId, String key, long id, int intValue, boolean enableBound, int bound) {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package io.cryptolens.models;
2+
3+
public class DecrementIntValueToMachineCodeModel extends ProductKeyMachineCodeModel {
4+
5+
/**
6+
* The unique object id for the data object.
7+
*/
8+
public long Id;
9+
10+
/**
11+
* The constant int value that should be subtracted to the current IntValue of the data object. For example,
12+
* if this value is set to 5 and the old IntValue is 11, then the new IntValue will be the old one minus 5, i.e. 6.
13+
* Note, if you would set this value to -5 instead, the same result would be achieved.
14+
*/
15+
public int IntValue;
16+
17+
/**
18+
* If set to true, it will be possible to specify a lower bound. For example, if you set the Bound parameter
19+
* (below) to 0, you will be able to decrement the int value until you reach zero (inclusive).
20+
* Once the lower bound is reached, an error will be thrown.
21+
*/
22+
public boolean EnableBound;
23+
24+
/**
25+
* This is the lower bound that will be enforced on the decrement operation.
26+
* It will only be enforced if EnableBound is set to true. Please read the description above.
27+
*/
28+
public int Bound;
29+
30+
public DecrementIntValueToMachineCodeModel(int productId, String key, String machineCode, long id, int intValue, boolean enableBound, int bound) {
31+
Id = id;
32+
IntValue = intValue;
33+
this.ProductId = productId;
34+
this.Key = key;
35+
this.EnableBound = enableBound;
36+
this.Bound = bound;
37+
this.MachineCode = machineCode;
38+
}
39+
40+
}

src/main/java/io/cryptolens/models/IncrementIntValueToKeyModel.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
package io.cryptolens.models;
22

33
public class IncrementIntValueToKeyModel extends ProductAndKeyModel {
4+
/**
5+
* The unique object id for the data object.
6+
*/
47
public long Id;
8+
/**
9+
* The constant int (non-negative) value that should be added to the current IntValue of the data object.
10+
* For example, if this value is set to 5 and the old IntValue is 1, then the new IntValue will be the
11+
* old one plus 5, i.e. 6. Note, if you would set this value to -5 instead, the same result would be achieved.
12+
*/
513
public int IntValue;
14+
/**
15+
* If set to true, it will be possible to specify an upper bound. For example, if you set the Bound parameter
16+
* (below) to 10, you will be able to increment the int value until you reach ten (inclusive).
17+
* Once the upper bound is reached, an error will be thrown.
18+
*/
619
public boolean EnableBound;
20+
21+
/**
22+
* This is the upper bound that will be enforced on the increment operation.
23+
* It will only be enforced if EnableBound is set to true. Please read the description above.
24+
*/
725
public int Bound;
826

927
public IncrementIntValueToKeyModel(int productId, String key, long id, int intValue, boolean enableBound, int bound) {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package io.cryptolens.models;
2+
3+
public class IncrementIntValueToMachineCodeModel extends ProductKeyMachineCodeModel {
4+
5+
/**
6+
* The unique object id for the data object.
7+
*/
8+
public long Id;
9+
/**
10+
* The constant int (non-negative) value that should be added to the current IntValue of the data object.
11+
* For example, if this value is set to 5 and the old IntValue is 1, then the new IntValue will be the
12+
* old one plus 5, i.e. 6. Note, if you would set this value to -5 instead, the same result would be achieved.
13+
*/
14+
public int IntValue;
15+
/**
16+
* If set to true, it will be possible to specify an upper bound. For example, if you set the Bound parameter
17+
* (below) to 10, you will be able to increment the int value until you reach ten (inclusive).
18+
* Once the upper bound is reached, an error will be thrown.
19+
*/
20+
public boolean EnableBound;
21+
22+
/**
23+
* This is the upper bound that will be enforced on the increment operation.
24+
* It will only be enforced if EnableBound is set to true. Please read the description above.
25+
*/
26+
public int Bound;
27+
28+
public IncrementIntValueToMachineCodeModel(int productId, String key, String machineCode, long id, int intValue, boolean enableBound, int bound) {
29+
Id = id;
30+
this.IntValue = intValue;
31+
this.ProductId = productId;
32+
this.Key = key;
33+
this.EnableBound = enableBound;
34+
this.Bound = bound;
35+
this.MachineCode = machineCode;
36+
}
37+
}

src/main/java/io/cryptolens/models/ListDataObjectsToKeyModel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package io.cryptolens.models;
22

33
public class ListDataObjectsToKeyModel extends ProductAndKeyModel {
4+
5+
/**
6+
* Shows only Data Objects where the name contains the following string.
7+
*/
48
public String Contains = "";
59

610
public ListDataObjectsToKeyModel(int productId, String key, String contains) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.cryptolens.models;
2+
3+
public class ListDataObjectsToMachineCodeModel extends ProductKeyMachineCodeModel {
4+
5+
/**
6+
* Shows only Data Objects where the name contains the following string.
7+
*/
8+
public String Contains = "";
9+
10+
public ListDataObjectsToMachineCodeModel(int productId, String key, String machineCode, String contains) {
11+
Contains = contains;
12+
this.ProductId = productId;
13+
this.Key = key;
14+
this.MachineCode = machineCode;
15+
}
16+
17+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.cryptolens.models;
2+
3+
public class ProductKeyMachineCodeModel extends ProductAndKeyModel {
4+
5+
/**
6+
* The machine code (identifier of an activated device).
7+
*/
8+
public String MachineCode;
9+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.cryptolens.models;
2+
3+
public class RemoveDataObjectToMachineCodeModel extends ProductKeyMachineCodeModel {
4+
/**
5+
* The unique id of the data object to be removed.
6+
*/
7+
public long Id;
8+
9+
public RemoveDataObjectToMachineCodeModel(int productId, String key, String machineCode, long id) {
10+
Id = id;
11+
this.ProductId = productId;
12+
this.Key = key;
13+
this.MachineCode = machineCode;
14+
}
15+
}

0 commit comments

Comments
 (0)