OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
LifespanImpl.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;
26 import org.omg.dds.core.policy.Lifespan;
30 
31 public class LifespanImpl extends QosPolicyImpl implements Lifespan {
32  private static final long serialVersionUID = 7903452866315787071L;
33  private final Duration duration;
34 
36  super(environment);
37  this.duration = environment.getSPI().infiniteDuration();
38  }
39 
41  super(environment);
42 
43  if (duration == null) {
44  throw new IllegalArgumentExceptionImpl(environment,
45  "Supplied invalid duration.");
46  }
47  this.duration = duration;
48  }
49 
50  @Override
51  public Duration getDuration() {
52  return this.duration;
53  }
54 
55  @Override
56  public Lifespan withDuration(Duration duration) {
57  return new LifespanImpl(this.environment, duration);
58  }
59 
60  @Override
61  public Lifespan withDuration(long duration, TimeUnit unit) {
62  return new LifespanImpl(this.environment, this.environment.getSPI()
63  .newDuration(duration, unit));
64  }
65 
66  @Override
67  public Class<? extends QosPolicy> getPolicyClass() {
68  return Lifespan.class;
69  }
70 
71  @Override
72  public boolean equals(Object other) {
73  if (!(other instanceof LifespanImpl)) {
74  return false;
75  }
76  return this.duration.equals(((LifespanImpl) other).duration);
77  }
78 
79  @Override
80  public int hashCode() {
81  return 31 * 17 + this.duration.hashCode();
82  }
83 
84 }
LifespanImpl(OsplServiceEnvironment environment)
Lifespan withDuration(Duration duration)
Copy this policy and override the value of the property.
Lifespan withDuration(long duration, TimeUnit unit)
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
LifespanImpl(OsplServiceEnvironment environment, Duration duration)
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
Specifies the maximum duration of validity of the data written by the org.omg.dds.pub.DataWriter.
Definition: Lifespan.java:57
Class<? extends QosPolicy > getPolicyClass()