|
|
|
@ -15,23 +15,31 @@ |
|
|
|
*/ |
|
|
|
package org.thingsboard.server.common.data.id; |
|
|
|
|
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonCreator; |
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty; |
|
|
|
import io.swagger.annotations.ApiModelProperty; |
|
|
|
import org.springframework.util.ConcurrentReferenceHashMap; |
|
|
|
import org.springframework.util.ConcurrentReferenceHashMap.ReferenceType; |
|
|
|
import org.thingsboard.server.common.data.EntityType; |
|
|
|
|
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
public final class TenantId extends UUIDBased implements EntityId { |
|
|
|
|
|
|
|
@JsonIgnore |
|
|
|
public static final TenantId SYS_TENANT_ID = new TenantId(EntityId.NULL_UUID); |
|
|
|
|
|
|
|
static final ConcurrentReferenceHashMap<UUID, TenantId> tenants = new ConcurrentReferenceHashMap<>(16, ReferenceType.SOFT); |
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L; |
|
|
|
|
|
|
|
@JsonCreator |
|
|
|
public TenantId(@JsonProperty("id") UUID id) { |
|
|
|
public static TenantId fromUUID(@JsonProperty("id") UUID id) { |
|
|
|
return tenants.computeIfAbsent(id, TenantId::new); |
|
|
|
} |
|
|
|
|
|
|
|
public TenantId(UUID id) { |
|
|
|
super(id); |
|
|
|
} |
|
|
|
|
|
|
|
|