OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
PartitionImpl.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.Collection;
24 import java.util.Collections;
25 import java.util.HashSet;
26 import java.util.Set;
27 
32 
33 public class PartitionImpl extends QosPolicyImpl implements Partition {
34  private static final long serialVersionUID = 3060990234546666051L;
35  private final HashSet<String> name;
36 
38  super(environment);
39  this.name = new HashSet<String>();
40  this.name.add("");
41  }
42 
44  Collection<String> name) {
45  super(environment);
46 
47  if (name == null) {
48  throw new IllegalArgumentExceptionImpl(environment,
49  "Supplied name is invalid.");
50  }
51  this.name = new HashSet<String>(name);
52 
53  if(this.name.size() == 0){
54  this.name.add("");
55  }
56  }
57 
59  String... name) {
60  super(environment);
61  this.name = new HashSet<String>();
62 
63  for(String partition: name){
64  this.name.add(partition);
65  }
66  if(this.name.size() == 0){
67  this.name.add("");
68  }
69  }
70 
71  @Override
72  public Set<String> getName() {
73  return Collections.unmodifiableSet(this.name);
74  }
75 
76  @Override
77  public Partition withName(Collection<String> name) {
78  return new PartitionImpl(this.environment, name);
79  }
80 
81  @Override
82  public Partition withName(String... names) {
83  return new PartitionImpl(this.environment, names);
84  }
85 
86  @Override
87  public Class<? extends QosPolicy> getPolicyClass() {
88  return Partition.class;
89  }
90 
91  @Override
92  public Partition withName(String name) {
93  return new PartitionImpl(this.environment, name);
94  }
95 
96  @Override
97  public boolean equals(Object other) {
98  if (!(other instanceof PartitionImpl)) {
99  return false;
100  }
101  PartitionImpl p = (PartitionImpl) other;
102 
103  if (this.name.size() != p.name.size()) {
104  return false;
105  }
106  if (!this.name.containsAll(p.name)) {
107  return false;
108  }
109  return true;
110  }
111 
112  @Override
113  public int hashCode() {
114  final int prime = 31;
115  int result = 17;
116 
117  for (String name : this.name) {
118  result = prime * result + name.hashCode();
119  }
120  return result;
121  }
122 }
PartitionImpl(OsplServiceEnvironment environment, String... name)
PartitionImpl(OsplServiceEnvironment environment, Collection< String > name)
Class<? extends QosPolicy > getPolicyClass()
This policy allows the introduction of a logical partition concept inside the "physical" partition in...
Definition: Partition.java:86
Partition withName(String... names)
Copy this policy and override the value of the property.
Partition withName(String name)
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
Partition withName(Collection< String > name)
Copy this policy and override the value of the property.
PartitionImpl(OsplServiceEnvironment environment)