import io.cryptolens.internal.*;
import io.cryptolens.methods.*;
import io.cryptolens.models.*;

public class Main {

    public static void main(String[] args) {

        // note, if we ran Key Verification earlier, we can can set Key=license.KeyString

        String auth = "WyIyOTA3IiwiMnNwUTFnb1JNQUt5U204UzR4ZzVkRUpQaWV6cEVXbCtrSkRod2pRTCJd";

        ListOfDataObjectsResult listResult = Data.ListDataObjects(auth, new ListDataObjectsToKeyModel(3941, "FRQHQ-FSOSD-BWOPU-KJOWF", "usagecount"));

        if (!Helpers.IsSuccessful(listResult)) {
            System.out.println("Could not list the data objects.");
        }

        if (listResult.DataObjects == null) {
            BasicResult addResult = Data.AddDataObject(auth,
                    new AddDataObjectToKeyModel(
                            3941,
                            "FRQHQ-FSOSD-BWOPU-KJOWF",
                            "usagecount",
                            0,
                            ""));

            if (!Helpers.IsSuccessful(addResult)) {
                System.out.println("Could not add a new data object. Maybe the limit was reached?");
            }
        } else {
            // if you set enableBound=true and bound=50 (as an example)
            // it won't be possible to increase to a value greater than 50.
            BasicResult incrementResult = Data.IncrementIntValue(auth,
                    new IncrementIntValueToKeyModel(
                            3941,
                            "FRQHQ-FSOSD-BWOPU-KJOWF",
                            listResult.DataObjects.get(0).Id,
                            1,
                            false,
                            0));

            if(!Helpers.IsSuccessful(incrementResult)) {
                System.out.println("Could not increment the data object");
            }
        }
    }
}

@@ -1844,11 +1844,910 @@
  %7D%0A    %7D
+%0A%0A    public static void main2() %7B%0A        String auth = %22WyIyOTA3IiwiMnNwUTFnb1JNQUt5U204UzR4ZzVkRUpQaWV6cEVXbCtrSkRod2pRTCJd%22;%0A%0A        ListOfDataObjectsResult listResult = Data.ListDataObjects(auth, new ListDataObjectsToKeyModel(3941, %22FRQHQ-FSOSD-BWOPU-KJOWF%22, %22usagecount%22));%0A%0A        if (!Helpers.IsSuccessful(listResult)) %7B%0A            System.out.println(%22Could not list the data objects.%22);%0A        %7D%0A%0A        BasicResult decrementResult = Data.DecrementIntValue(auth,%0A                new DecrementIntValueToKeyModel(%0A                        3941,%0A                        %22FRQHQ-FSOSD-BWOPU-KJOWF%22,%0A                        listResult.DataObjects.get(0).Id,%0A                        1,%0A                        true,%0A                        0));%0A%0A        if(!Helpers.IsSuccessful(decrementResult)) %7B%0A            System.out.println(%22Could not decrement the data object%22);%0A        %7D%0A    %7D%0A%0A%0A    %7D
 %0A%7D%0A

Add decrement example