OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
DurabilityImpl.java
Go to the documentation of this file.
1 /*
2  * Vortex OpenSplice
3  *
4  * This software and documentation are Copyright 2006 to 2024 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 DurabilityImpl extends QosPolicyImpl implements Durability {
29  private static final long serialVersionUID = -3661996204819852834L;
30  private final Kind kind;
31 
33  super(environment);
34  this.kind = Kind.VOLATILE;
35  }
36 
38  super(environment);
39  this.kind = kind;
40 
41  if (this.kind == null) {
42  throw new IllegalArgumentExceptionImpl(environment,
43  "Supplied kind is null.");
44  }
45  }
46 
47  @Override
48  public Comparable<Durability> requestedOfferedContract() {
49  return this;
50  }
51 
52  @Override
53  public int compareTo(Durability o) {
54  // VOLATILE<TRANSIENT_LOCAL<TRANSIENT<PERSISTENT
55  Kind other = o.getKind();
56 
57  if (other.equals(this.kind)) {
58  return 0;
59  } else if (other.equals(Kind.VOLATILE)) {
60  return 1;
61  } else if (other.equals(Kind.TRANSIENT_LOCAL)) {
62  if (this.kind.equals(Kind.VOLATILE)) {
63  return -1;
64  }
65  return 1;
66  } else if (other.equals(Kind.TRANSIENT)) {
67  if (this.kind.equals(Kind.VOLATILE)
68  || this.kind.equals(Kind.TRANSIENT_LOCAL)) {
69  return -1;
70  }
71  return 1;
72  }
73  return -1;
74  }
75 
76  @Override
77  public boolean equals(Object other) {
78  if (!(other instanceof DurabilityImpl)) {
79  return false;
80  }
81  return (this.kind == ((DurabilityImpl) other).kind);
82  }
83 
84  @Override
85  public int hashCode() {
86  return 31 * 17 + this.kind.hashCode();
87  }
88 
89  @Override
90  public Kind getKind() {
91  return this.kind;
92  }
93 
94  @Override
95  public Durability withKind(Kind kind) {
96  return new DurabilityImpl(this.environment, kind);
97  }
98 
99  @Override
101  return new DurabilityImpl(this.environment, Kind.VOLATILE);
102  }
103 
104  @Override
107  }
108 
109  @Override
111  return new DurabilityImpl(this.environment, Kind.TRANSIENT);
112  }
113 
114  @Override
116  return new DurabilityImpl(this.environment, Kind.PERSISTENT);
117  }
118 
119  @Override
120  public Class<? extends QosPolicy> getPolicyClass() {
121  return Durability.class;
122  }
123 }
VOLATILE
The Service does not need to keep any samples of data instances on behalf of any org.omg.dds.sub.DataReader that is not known by the org.omg.dds.pub.DataWriter at the time the instance is written.
DurabilityImpl(OsplServiceEnvironment environment, Kind kind)
Durability withKind(Kind kind)
Copy this policy and override the value of the property.
TRANSIENT
The Service will attempt to keep some samples so that they can be delivered to any potential late-joi...
PERSISTENT
Data is kept on permanent storage, so that they can outlive a system session.
Class<? extends QosPolicy > getPolicyClass()
This class is the abstract root for all the QoS policies.
Definition: QosPolicy.java:118
TRANSIENT_LOCAL
The Service will attempt to keep some samples so that they can be delivered to any potential late-joi...
Comparable< Durability > requestedOfferedContract()
DurabilityImpl(OsplServiceEnvironment environment)
This policy expresses if the data should "outlive" their writing time.