2019-08-09 19:13:18 +03:00
|
|
|
///
|
2022-01-17 14:07:46 +02:00
|
|
|
/// Copyright © 2016-2022 The Thingsboard Authors
|
2019-08-09 19:13:18 +03:00
|
|
|
///
|
|
|
|
|
/// 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
|
|
|
|
|
/// limitations under the License.
|
|
|
|
|
///
|
|
|
|
|
|
2020-04-27 09:27:14 +03:00
|
|
|
import { AliasEntityType, EntityType } from '@shared/models/entity-type.models';
|
2019-08-09 19:13:18 +03:00
|
|
|
import { HasUUID } from '@shared/models/id/has-uuid';
|
2020-08-27 19:32:15 +03:00
|
|
|
import { isDefinedAndNotNull } from '@core/utils';
|
2019-08-09 19:13:18 +03:00
|
|
|
|
|
|
|
|
export interface EntityId extends HasUUID {
|
2019-08-19 20:09:41 +03:00
|
|
|
entityType: EntityType | AliasEntityType;
|
2019-08-09 19:13:18 +03:00
|
|
|
}
|
2020-08-27 19:32:15 +03:00
|
|
|
|
|
|
|
|
export function entityIdEquals(entityId1: EntityId, entityId2: EntityId): boolean {
|
|
|
|
|
if (isDefinedAndNotNull(entityId1) && isDefinedAndNotNull(entityId2)) {
|
|
|
|
|
return entityId1.id === entityId2.id && entityId1.entityType === entityId2.entityType;
|
|
|
|
|
} else {
|
|
|
|
|
return entityId1 === entityId2;
|
|
|
|
|
}
|
|
|
|
|
}
|