1 22 23 package org.objectweb.petals.tools.jbicommon.descriptor; 24 25 import javax.xml.namespace.QName ; 26 27 import org.apache.commons.lang.builder.EqualsBuilder; 28 import org.apache.commons.lang.builder.HashCodeBuilder; 29 import org.apache.commons.lang.builder.ToStringBuilder; 30 31 62 public class Consumes extends ExtensibleJbiElement { 63 64 67 public static final String HARD_LINK_TYPE = "hard"; 68 69 72 public static final String SOFT_LINK_TYPE = "soft"; 73 74 77 public static final String STD_LINK_TYPE = "standard"; 78 79 82 private String endpointName; 83 84 87 private QName interfaceName; 88 89 92 private String linkType; 93 94 97 private QName serviceName; 98 99 102 public Consumes() { super(); 104 } 105 106 @Override 107 public boolean equals(final Object other) { 108 if (!(other instanceof Consumes)) { 109 return false; } 111 Consumes castOther = (Consumes) other; 112 return new EqualsBuilder().append(endpointName, castOther.endpointName) 113 .append(interfaceName, castOther.interfaceName).append( 114 linkType, castOther.linkType).append(serviceName, 115 castOther.serviceName).isEquals(); 116 } 117 118 124 public String getEndpointName() { 125 return endpointName; 126 } 127 128 133 public QName getInterfaceName() { 134 return interfaceName; 135 } 136 137 144 public String getLinkType() { 145 return linkType; 146 } 147 148 152 158 public QName getServiceName() { 159 return serviceName; 160 } 161 162 @Override 163 public int hashCode() { 164 return new HashCodeBuilder().append(endpointName).append(interfaceName) 165 .append(linkType).append(serviceName).toHashCode(); 166 } 167 168 171 public boolean isHardLink() { 172 return (hasQualifiedEndpoint()) 173 && (linkType != null && linkType.equals(HARD_LINK_TYPE)); 174 } 175 176 179 public boolean isSoftLink() { 180 return (hasQualifiedEndpoint()) 181 && (linkType != null && linkType.equals(SOFT_LINK_TYPE)); 182 } 183 184 187 public boolean isStandardLink() { 188 return (hasQualifiedEndpoint()) 189 && (linkType == null || linkType.equals(STD_LINK_TYPE)); 190 } 191 192 @Override 193 public String toString() { 194 return new ToStringBuilder(this).append("endpointName", endpointName) 195 .append("interfaceName", interfaceName).append("linkType", 196 linkType).append("serviceName", serviceName).toString(); 197 } 198 199 203 boolean hasQualifiedEndpoint() { 204 return serviceName != null && endpointName != null; 205 } 206 207 211 218 void setEndpointName(final String endpointName) { 219 this.endpointName = endpointName; 220 } 221 222 228 void setInterfaceName(final QName interfaceName) { 229 this.interfaceName = interfaceName; 230 } 231 232 238 void setLinkType(final String type) { 239 this.linkType = type; 240 } 241 242 249 void setServiceName(final QName serviceName) { 250 this.serviceName = serviceName; 251 } 252 } 253 | Popular Tags |