DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
ObjectId.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 
19 namespace Deveel.Data.Store {
31  public struct ObjectId : IEquatable<ObjectId> {
38  public ObjectId(int storeId, long id)
39  : this() {
40  if (storeId < 0)
41  throw new ArgumentOutOfRangeException("storeId");
42  if (id < 0)
43  throw new ArgumentOutOfRangeException("id");
44 
45  StoreId = storeId;
46  Id = id;
47  }
48 
56  public int StoreId { get; private set; }
57 
65  public long Id { get; private set; }
66 
68  public override bool Equals(object obj) {
69  return Equals((ObjectId)obj);
70  }
71 
73  public override int GetHashCode() {
74  return unchecked ((int)(StoreId*47 ^ Id));
75  }
76 
78  public bool Equals(ObjectId other) {
79  return StoreId == other.StoreId &&
80  Id == other.Id;
81  }
82 
84  public override string ToString() {
85  return String.Format("0x{0:X}:{1:X}", StoreId, Id);
86  }
87  }
88 }
long Id
Gets the unique identifier of the object within the containing store.
Definition: ObjectId.cs:65
override int GetHashCode()
Definition: ObjectId.cs:73
override string ToString()
Definition: ObjectId.cs:84
bool Equals(ObjectId other)
Definition: ObjectId.cs:78
A unique identifier of an object within a database system, that is composed by a reference to the sto...
Definition: ObjectId.cs:31
int StoreId
Gets the unique identifier of the store that contains the object.
Definition: ObjectId.cs:56
ObjectId(int storeId, long id)
Constructs the ObjectId with the given references to the store and the address.
Definition: ObjectId.cs:38
override bool Equals(object obj)
Definition: ObjectId.cs:68