OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
ReaderDataLifecycleImpl.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 
23 import java.util.concurrent.TimeUnit;
24 
25 import org.omg.dds.core.Duration;
30 
31 public class ReaderDataLifecycleImpl extends QosPolicyImpl implements
32  org.opensplice.dds.core.policy.ReaderDataLifecycle {
33  private static final long serialVersionUID = 6465409872651281346L;
34  private final Duration autoPurgeNoWriterSamplesDelay;
35  private final Duration autoPurgeDisposedSamplesDelay;
36  private final boolean autoPurgeDisposeAll;
37  private Kind invalidSampleVisibility;
38 
40  super(environment);
41  this.autoPurgeNoWriterSamplesDelay = environment.getSPI()
43  this.autoPurgeDisposedSamplesDelay = environment.getSPI()
45  this.autoPurgeDisposeAll = false;
46  this.invalidSampleVisibility = Kind.MINIMUM;
47  }
48 
50  Duration autoPurgeNoWriterSamplesDelay,
51  Duration autoPurgeDisposedSamplesDelay,
52  boolean autoPurgeDisposeAll,
53  Kind invalidSampleVisibility) {
54  super(environment);
55 
56  if (autoPurgeNoWriterSamplesDelay == null) {
57  throw new IllegalArgumentExceptionImpl(environment,
58  "Supplied invalid autoPurgeNoWriterSamplesDelay duration.");
59  }
60  if (autoPurgeDisposedSamplesDelay == null) {
61  throw new IllegalArgumentExceptionImpl(environment,
62  "Supplied invalid autoPurgeDisposedSamplesDelay duration.");
63  }
64  if (invalidSampleVisibility == null) {
65  throw new IllegalArgumentExceptionImpl(environment,
66  "Supplied invalid invalidSampleVisibility.");
67  }
68  this.autoPurgeNoWriterSamplesDelay = autoPurgeNoWriterSamplesDelay;
69  this.autoPurgeDisposedSamplesDelay = autoPurgeDisposedSamplesDelay;
70  this.autoPurgeDisposeAll = autoPurgeDisposeAll;
71  this.invalidSampleVisibility = invalidSampleVisibility;
72  }
73 
74  @Override
76  return this.autoPurgeNoWriterSamplesDelay;
77  }
78 
79  @Override
81  return this.autoPurgeDisposedSamplesDelay;
82  }
83 
84  @Override
85  public boolean getAutoPurgeDisposeAll() {
86  return this.autoPurgeDisposeAll;
87  }
88 
89  @Override
91  return this.invalidSampleVisibility;
92  }
93 
94  @Override
96  Duration autoPurgeNoWriterSamplesDelay) {
97  return new ReaderDataLifecycleImpl(this.environment,
98  autoPurgeNoWriterSamplesDelay,
99  this.autoPurgeDisposedSamplesDelay,
100  this.autoPurgeDisposeAll,
101  this.invalidSampleVisibility);
102  }
103 
104  @Override
106  long autoPurgeNoWriterSamplesDelay, TimeUnit unit) {
107  return new ReaderDataLifecycleImpl(this.environment, this.environment
108  .getSPI().newDuration(autoPurgeNoWriterSamplesDelay, unit),
109  this.autoPurgeDisposedSamplesDelay,
110  this.autoPurgeDisposeAll,
111  this.invalidSampleVisibility);
112  }
113 
114  @Override
116  Duration autoPurgeDisposedSamplesDelay) {
117  return new ReaderDataLifecycleImpl(this.environment,
118  this.autoPurgeNoWriterSamplesDelay,
119  autoPurgeDisposedSamplesDelay,
120  this.autoPurgeDisposeAll,
121  this.invalidSampleVisibility);
122  }
123 
124  @Override
126  return new ReaderDataLifecycleImpl(this.environment,
127  this.autoPurgeNoWriterSamplesDelay,
128  this.autoPurgeDisposedSamplesDelay,
129  true,
130  this.invalidSampleVisibility);
131  }
132 
133  @Override
135  Kind kind) {
136  return new ReaderDataLifecycleImpl(this.environment,
137  this.autoPurgeNoWriterSamplesDelay,
138  this.autoPurgeDisposedSamplesDelay,
139  this.autoPurgeDisposeAll,
140  kind);
141  }
142 
143  @Override
145  long autoPurgeDisposedSamplesDelay, TimeUnit unit) {
146  return new ReaderDataLifecycleImpl(this.environment,
147  this.autoPurgeNoWriterSamplesDelay, this.environment.getSPI()
148  .newDuration(autoPurgeDisposedSamplesDelay, unit),
149  this.autoPurgeDisposeAll,
150  this.invalidSampleVisibility);
151  }
152 
153  @Override
154  public Class<? extends QosPolicy> getPolicyClass() {
155  return ReaderDataLifecycle.class;
156  }
157 
158  @Override
159  public boolean equals(Object other) {
160  if (!(other instanceof ReaderDataLifecycleImpl)) {
161  return false;
162  }
163  ReaderDataLifecycleImpl r = (ReaderDataLifecycleImpl) other;
164 
165  if (this.autoPurgeDisposeAll != r.autoPurgeDisposeAll) {
166  return false;
167  }
168  if (this.invalidSampleVisibility != r.invalidSampleVisibility) {
169  return false;
170  }
171  if (!this.autoPurgeDisposedSamplesDelay
172  .equals(r.autoPurgeDisposedSamplesDelay)) {
173  return false;
174  }
175  return this.autoPurgeNoWriterSamplesDelay
176  .equals(r.autoPurgeNoWriterSamplesDelay);
177  }
178 
179  @Override
180  public int hashCode() {
181  final int prime = 31;
182  int result = 17;
183 
184  result = prime * result + (this.autoPurgeDisposeAll ? 1 : 0);
185  result = prime * result + this.autoPurgeDisposedSamplesDelay.hashCode();
186 
187  return prime * result + this.autoPurgeNoWriterSamplesDelay.hashCode();
188  }
189 }
Specifies the behavior of the org.omg.dds.sub.DataReader with regards to the life cycle of the data i...
This class provides OpenSplice-specific extensions to the org.omg.dds.core.policy.ReaderDataLifecycle policy.
ReaderDataLifecycle withAutoPurgeNoWriterSamplesDelay(Duration autoPurgeNoWriterSamplesDelay)
Copy this policy and override the value of the property.
ReaderDataLifecycleImpl(OsplServiceEnvironment environment, Duration autoPurgeNoWriterSamplesDelay, Duration autoPurgeDisposedSamplesDelay, boolean autoPurgeDisposeAll, Kind invalidSampleVisibility)
org.opensplice.dds.core.policy.ReaderDataLifecycle withAutoPurgeDisposeAll()
ReaderDataLifecycle withAutoPurgeDisposedSamplesDelay(Duration autoPurgeDisposedSamplesDelay)
Copy this policy and override the value of the property.
This class is the abstract root for all the QoS policies.
Definition: QosPolicy.java:118
ReaderDataLifecycle withAutoPurgeDisposedSamplesDelay(long autoPurgeDisposedSamplesDelay, TimeUnit unit)
Copy this policy and override the value of the property.
Duration newDuration(long duration, TimeUnit unit)
Construct a org.omg.dds.core.Duration of the given magnitude.
A span of elapsed time expressed with nanosecond precision.
Definition: Duration.java:35
ReaderDataLifecycle withAutoPurgeNoWriterSamplesDelay(long autoPurgeNoWriterSamplesDelay, TimeUnit unit)
Copy this policy and override the value of the property.
org.opensplice.dds.core.policy.ReaderDataLifecycle withInvalidSampleInvisibility(Kind kind)