OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
ViewKeysImpl.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 
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.HashSet;
26 import java.util.Set;
27 
30 
31 public class ViewKeysImpl extends QosPolicyImpl implements ViewKeys {
32  private static final long serialVersionUID = -4786321587154092502L;
33  private final HashSet<String> keyList;
34 
35  public ViewKeysImpl(OsplServiceEnvironment environment, String... keyValue) {
36  super(environment);
37  this.keyList = new HashSet<String>();
38 
39  for (String k : keyValue) {
40  this.keyList.add(k);
41  }
42  }
43 
45  Collection<String> keyValue) {
46  super(environment);
47  this.keyList = new HashSet<String>();
48 
49  if (keyValue != null) {
50  for (String k : keyValue) {
51  this.keyList.add(k);
52  }
53  }
54  }
55 
56  @Override
57  public Set<String> getKey() {
58  return Collections.unmodifiableSet(this.keyList);
59  }
60 
61  @Override
62  public ViewKeys withKey(Collection<String> keyList) {
63  return new ViewKeysImpl(this.environment, keyList);
64  }
65 
66  @Override
67  public ViewKeys withKey(String keyList) {
68  return new ViewKeysImpl(this.environment, keyList);
69  }
70 
71  @Override
72  public ViewKeys withKey(String... keyList) {
73  return new ViewKeysImpl(this.environment, keyList);
74  }
75 
76  @Override
77  public Class<? extends QosPolicy> getPolicyClass() {
78  return ViewKeys.class;
79  }
80 
81  @Override
82  public boolean equals(Object other) {
83  if (!(other instanceof ViewKeysImpl)) {
84  return false;
85  }
86  ViewKeysImpl v = (ViewKeysImpl) other;
87 
88  if (v.keyList.size() != this.keyList.size()) {
89  return false;
90  }
91  return v.keyList.containsAll(this.keyList);
92  }
93 
94  @Override
95  public int hashCode() {
96  final int prime = 31;
97  int result = 17;
98 
99  for (String key : this.keyList) {
100  result = prime * result + key.hashCode();
101  }
102  return result;
103  }
104 }
Class<? extends QosPolicy > getPolicyClass()
ViewKeys withKey(String keyList)
Copy this policy and override the value of the property.
ViewKeys withKey(Collection< String > keyList)
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
ViewKeys withKey(String... keyList)
Copy this policy and override the value of the property.
ViewKeysImpl(OsplServiceEnvironment environment, String... keyValue)
ViewKeysImpl(OsplServiceEnvironment environment, Collection< String > keyValue)
This QosPolicy is used to set the key list of a DataReaderView.
Definition: ViewKeys.java:54