/**
 * Copyright 2016 Eventchain team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 */
package org.eventchain;

import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.eventchain.hlc.HybridTimestamp;
import org.eventchain.layout.LayoutIgnore;

import java.util.UUID;

public class Entity {

    @Setter @Accessors(fluent = true)
    private UUID uuid;

    @LayoutIgnore
    public UUID uuid() {
        if (uuid == null) {
            uuid = UUID.randomUUID();
        }
        return uuid;
    }

    @Getter(onMethod = @__(@LayoutIgnore)) @Setter @Accessors(fluent = true)
    private HybridTimestamp timestamp;

}

@@ -780,30 +780,520 @@
 ID;%0A
-%0Apublic class Entity %7B
+import java.util.concurrent.BlockingDeque;%0Aimport java.util.concurrent.ForkJoinPool;%0Aimport java.util.concurrent.LinkedBlockingDeque;%0A%0Apublic class Entity %7B%0A%0A    private static LinkedBlockingDeque%3CUUID%3E uuids = new LinkedBlockingDeque%3C%3E(1_000_000);%0A%0A    static %7B%0A        ForkJoinPool.commonPool().execute(() -%3E %7B%0A            while (true) %7B%0A                try %7B%0A                    uuids.put(UUID.randomUUID());%0A                %7D catch (InterruptedException e) %7B%0A                %7D%0A            %7D%0A        %7D);%0A    %7D
 %0A%0A  
@@ -1403,18 +1403,21 @@
         
-if
+while
  (uuid =
@@ -1442,33 +1442,111 @@
     
-uuid = UUID.randomUUID();
+try %7B%0A                uuid = uuids.take();%0A            %7D catch (InterruptedException e) %7B%0A            %7D
 %0A   

Improve Entity UUID generation time by pre-generating them