OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
HistoryImpl.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 org.omg.dds.core.policy.History;
27 
28 public class HistoryImpl extends QosPolicyImpl implements History{
29  private static final long serialVersionUID = 8740123506122702059L;
30  private final Kind kind;
31  private final int depth;
32 
34  super(environment);
35  this.kind = Kind.KEEP_LAST;
36  this.depth = 1;
37  }
38 
40  super(environment);
41 
42  if (kind == null) {
43  throw new IllegalArgumentExceptionImpl(environment,
44  "Supplied invalid kind.");
45  }
46  this.kind = kind;
47  this.depth = depth;
48  }
49 
50  @Override
51  public Kind getKind() {
52  return this.kind;
53  }
54 
55  @Override
56  public int getDepth() {
57  return this.depth;
58  }
59 
60  @Override
61  public History withKind(Kind kind) {
62  return new HistoryImpl(this.environment, kind, this.depth);
63  }
64 
65  @Override
66  public History withDepth(int depth) {
67  return new HistoryImpl(this.environment, this.kind, depth);
68 
69  }
70 
71  @Override
72  public History withKeepAll() {
73  return new HistoryImpl(this.environment, Kind.KEEP_ALL, this.depth);
74 
75  }
76 
77  @Override
78  public History withKeepLast(int depth) {
79  return new HistoryImpl(this.environment, Kind.KEEP_LAST, depth);
80 
81  }
82 
83  @Override
84  public Class<? extends QosPolicy> getPolicyClass() {
85  return History.class;
86  }
87 
88  @Override
89  public boolean equals(Object other) {
90  if (!(other instanceof HistoryImpl)) {
91  return false;
92  }
93  HistoryImpl h = (HistoryImpl) other;
94 
95  if (this.kind != h.kind) {
96  return false;
97  }
98  return (this.depth == h.depth);
99  }
100 
101  @Override
102  public int hashCode() {
103  final int prime = 31;
104  int result = 17;
105 
106  result = prime * result + this.kind.hashCode();
107  result = prime * result + this.depth;
108 
109  return result;
110  }
111 }
HistoryImpl(OsplServiceEnvironment environment, Kind kind, int depth)
History withDepth(int depth)
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
HistoryImpl(OsplServiceEnvironment environment)
Class<? extends QosPolicy > getPolicyClass()
Specifies the behavior of the Service in the case where the value of a sample changes (one or more ti...
Definition: History.java:76