OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
OwnershipImpl.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.policy;
22 
27 
28 public class OwnershipImpl extends QosPolicyImpl implements Ownership {
29  private static final long serialVersionUID = 5349819428623413367L;
30  private final Kind kind;
31 
33  super(environment);
34  this.kind = Kind.SHARED;
35  }
36 
38  super(environment);
39 
40  if (kind == null) {
41  throw new IllegalArgumentExceptionImpl(environment,
42  "Supplied kind is invalid.");
43  }
44  this.kind = kind;
45  }
46 
47  @Override
48  public Comparable<Ownership> requestedOfferedContract() {
49  return this;
50  }
51 
52  @Override
53  public int compareTo(Ownership o) {
54  if (this.kind.equals(o.getKind())) {
55  return 0;
56  } else if (this.kind.equals(Kind.SHARED)) {
57  return -1;
58  }
59  return 1;
60  }
61 
62  @Override
63  public boolean equals(Object other) {
64  if (!(other instanceof OwnershipImpl)) {
65  return false;
66  }
67  return this.kind.equals(((OwnershipImpl) other).kind);
68  }
69 
70  @Override
71  public Kind getKind() {
72  return this.kind;
73  }
74 
75  @Override
76  public Ownership withKind(Kind kind) {
77  return new OwnershipImpl(this.environment, kind);
78  }
79 
80  @Override
81  public Ownership withShared() {
82  return new OwnershipImpl(this.environment, Kind.SHARED);
83  }
84 
85  @Override
87  return new OwnershipImpl(this.environment, Kind.EXCLUSIVE);
88  }
89 
90  @Override
91  public Class<? extends QosPolicy> getPolicyClass() {
92  return Ownership.class;
93  }
94 
95  @Override
96  public int hashCode() {
97  return 17 * 31 + this.kind.hashCode();
98  }
99 }
Ownership withKind(Kind kind)
Copy this policy and override the value of the property.
Comparable< Ownership > requestedOfferedContract()
Class<? extends QosPolicy > getPolicyClass()
EXCLUSIVE
Indicates each instance can only be owned by one org.omg.dds.pub.DataWriter, but the owner of an inst...
Definition: Ownership.java:120
SHARED
Indicates shared ownership for each instance.
Definition: Ownership.java:109
This class is the abstract root for all the QoS policies.
Definition: QosPolicy.java:118
OwnershipImpl(OsplServiceEnvironment environment, Kind kind)
OwnershipImpl(OsplServiceEnvironment environment)
This QosPolicy specifies whether a DataWriter exclusively may own an instance.
Definition: Ownership.java:63