OpenSplice Java 5 DCPS  v6.x
OpenSplice Java 5 OpenSplice Data Distribution Service Data-Centric Publish-Subscribe API
TypeConsistencyEnforcementImpl.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 
26 
28  private static final long serialVersionUID = -5160265825622794754L;
29  private final Kind kind;
30  private final transient OsplServiceEnvironment environment;
31 
33  this.environment = environment;
34  this.kind = kind;
35  }
36 
37  @Override
39  return this.environment;
40  }
41 
42  @Override
43  public Comparable<TypeConsistencyEnforcement> requestedOfferedContract() {
44  return this;
45  }
46 
47  @Override
49  Kind other = o.getKind();
50 
51  if(other.equals(this.kind)){
52  return 0;
53  } else if(this.kind.equals(Kind.EXACT_TYPE_TYPE_CONSISTENCY)){
54  return 1;
55  } else if(this.kind.equals(Kind.EXACT_NAME_TYPE_CONSISTENCY)){
56  if(other.equals(Kind.EXACT_TYPE_TYPE_CONSISTENCY)){
57  return -1;
58  }
59  return 1;
60  } else if(this.kind.equals(Kind.DECLARED_TYPE_CONSISTENCY)){
61  if(other.equals(Kind.ASSIGNABLE_TYPE_CONSISTENCY)){
62  return 1;
63  }
64  return -1;
65  }
66  return -1;
67  }
68 
69  @Override
70  public boolean equals(Object other) {
71  if (other instanceof TypeConsistencyEnforcementImpl) {
72  if (this.compareTo((TypeConsistencyEnforcementImpl) other) == 0) {
73  return true;
74  }
75  }
76  return false;
77  }
78 
79  @Override
80  public int hashCode() {
81  return 31 * 17 + this.kind.ordinal();
82  }
83 
84  @Override
85  public Kind getKind() {
86  return this.kind;
87  }
88 
89  @Override
91  return new TypeConsistencyEnforcementImpl(this.environment, kind);
92  }
93 
94  @Override
97  }
98 
99  @Override
102  }
103 
104  @Override
106  return new TypeConsistencyEnforcementImpl(this.environment, Kind.DECLARED_TYPE_CONSISTENCY);
107  }
108 
109  @Override
112  }
113 
114 }
TypeConsistencyEnforcement withKind(Kind kind)
Copy this policy and override the value of the property.
TypeConsistencyEnforcementImpl(OsplServiceEnvironment environment, Kind kind)
DDS implementations are rooted in this class, a concrete subclass of which can be instantiated based ...