package com.kryptnostic.v2.storage.models;

import java.util.Map;
import java.util.Set;
import java.util.UUID;

import javax.annotation.concurrent.Immutable;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.kryptnostic.v2.constants.Names;

@Immutable
public class ObjectTreeLoadRequest {
    private static final int                    DEFAULT_DEPTH = 0;
    private final Set<UUID>                     objectIds;
    private final Set<VersionedObjectKey>       objectIdsToFilter;
    private final Map<UUID, Set<LoadLevel>>     typeLoadLevels;
    private final Map<UUID, VersionedObjectKey> createdAfter;
    private final int                           loadDepth;

    public ObjectTreeLoadRequest( Set<UUID> objectIds, Map<UUID, Set<LoadLevel>> typeLoadLevels ) {
        this(
                objectIds,
                Optional.<Set<VersionedObjectKey>> absent(),
                typeLoadLevels,
                Optional.<Map<UUID, VersionedObjectKey>> absent(),
                Optional.of( DEFAULT_DEPTH ) );
    }

    @JsonCreator
    public ObjectTreeLoadRequest(
            @JsonProperty( Names.OBJECT_IDS ) Set<UUID> objectIds,
            @JsonProperty( Names.OBJECTS_FILTER ) Optional<Set<VersionedObjectKey>> objectIdsToFilter,
            @JsonProperty( Names.LOAD_LEVELS ) Map<UUID, Set<LoadLevel>> typeLoadLevels,
            @JsonProperty( Names.CREATED_AFTER ) Optional<Map<UUID, VersionedObjectKey>> createdAfter,
            @JsonProperty( Names.DEPTH ) Optional<Integer> loadDepth) {
        this.objectIds = objectIds;
        this.objectIdsToFilter = objectIdsToFilter.or( ImmutableSet.<VersionedObjectKey> of() );
        this.typeLoadLevels = typeLoadLevels;
        this.createdAfter = createdAfter.or( ImmutableMap.<UUID, VersionedObjectKey> of() );
        this.loadDepth = loadDepth.or( DEFAULT_DEPTH );
    }

    @JsonProperty( Names.OBJECT_IDS )
    public Set<UUID> getObjectIds() {
        return objectIds;
    }

    @JsonProperty( Names.OBJECTS_FILTER )
    public Set<VersionedObjectKey> getObjectIdsToFilter() {
        return objectIdsToFilter;
    }

    @JsonProperty( Names.LOAD_LEVELS )
    public Map<UUID, Set<LoadLevel>> getTypeLoadLevels() {
        return typeLoadLevels;
    }

    @JsonProperty( Names.CREATED_AFTER )
    public Map<UUID, VersionedObjectKey> getCreatedAfter() {
        return createdAfter;
    }

    @JsonProperty( Names.DEPTH )
    public int getLoadDepth() {
        return loadDepth;
    }
}

@@ -633,35 +633,35 @@
 nal Set%3C
-VersionedObjectKey%3E
+UUID%3E              
        o
@@ -1035,34 +1035,20 @@
 al.%3CSet%3C
-VersionedObjectKey
+UUID
 %3E%3E absen
@@ -1387,34 +1387,20 @@
 nal%3CSet%3C
-VersionedObjectKey
+UUID
 %3E%3E objec
@@ -1782,34 +1782,20 @@
 bleSet.%3C
-VersionedObjectKey
+UUID
 %3E of() )
@@ -2164,34 +2164,20 @@
 lic Set%3C
-VersionedObjectKey
+UUID
 %3E getObj

change objectIdsToFilter type from VersionedObjectKey to UUID