OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
InstanceHandleImpl.java
Go to the documentation of this file.
1 /*
2  * Vortex OpenSplice
3  *
4  * This software and documentation are Copyright 2006 to 2021 ADLINK
5  * Technology Limited, its affiliated companies and licensors. All rights
6  * reserved.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 package org.opensplice.dds.core;
22 
25 
26 public class InstanceHandleImpl extends InstanceHandle {
27  private static final long serialVersionUID = 8433681503549822293L;
28  private final transient OsplServiceEnvironment environment;
29  private final long value;
30 
31  public InstanceHandleImpl(OsplServiceEnvironment environment, long value) {
32  this.environment = environment;
33  this.value = value;
34  }
35 
36  @Override
37  public int compareTo(InstanceHandle o) {
38  InstanceHandleImpl other = null;
39 
40  if (o == null) {
41  return -1;
42  }
43 
44  try {
45  other = (InstanceHandleImpl)o;
46  } catch(ClassCastException cce){
47  throw new IllegalOperationExceptionImpl(this.environment,
48  "Cannot compare OpenSplice InstanceHandle to non-OpenSplice InstanceHandle");
49  }
50  if (this.value == other.getValue()) {
51  return 0;
52  }
53 
54  if (this.value < other.getValue()) {
55  return -1;
56  }
57  return 1;
58  }
59 
60  @Override
62  return this.environment;
63  }
64 
65  @Override
66  public boolean isNil() {
67  return (this.value == DDS.HANDLE_NIL.value);
68  }
69 
70  public long getValue(){
71  return this.value;
72  }
73 
74  @Override
75  public boolean equals(Object other){
76  if(other instanceof InstanceHandleImpl){
77  return (((InstanceHandleImpl)other).value == this.value);
78  }
79  return false;
80  }
81 
82  @Override
83  public String toString(){
84  return "InstanceHandle (" + this.value + ")";
85  }
86 
87  @Override
88  public int hashCode(){
89  return 31 * 17 + (int) (this.value ^ (this.value >>> 32));
90  }
91 }
InstanceHandleImpl(OsplServiceEnvironment environment, long value)
An opaque handle that can be used to refer to a local or remote entity.
DDS implementations are rooted in this class, a concrete subclass of which can be instantiated based ...