/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @param checkWeakness * The equality test takes care or not of the weakness. * * @return True if both tags are equal. */ public boolean equals(final Object object, boolean checkWeakness) { if (!(object instanceof Tag)) { return false; } final Tag that = (Tag) object; if (checkWeakness && that.isWeak() != isWeak()) { return false; } return Objects.equals(getName(), that.getName()); }
/** * Returns tag formatted as an HTTP tag string. * * @return The formatted HTTP tag string. * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP Entity Tags</a> */ public String format() { if (getName().equals("*")) { return "*"; } final StringBuilder sb = new StringBuilder(); if (isWeak()) { sb.append("W/"); } return sb.append('"').append(getName()).append('"').toString(); }
/** * Returns tag formatted as an HTTP tag string. * * @return The formatted HTTP tag string. * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP Entity Tags</a> */ public String format() { if ("*".equals(getName())) { return "*"; } final StringBuilder sb = new StringBuilder(); if (isWeak()) { sb.append("W/"); } return sb.append('"').append(getName()).append('"').toString(); }
/** * Returns tag formatted as an HTTP tag string. * * @return The formatted HTTP tag string. * @see <a * href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP * Entity Tags</a> */ public String format() { if (getName().equals("*")) { return "*"; } final StringBuilder sb = new StringBuilder(); if (isWeak()) { sb.append("W/"); } return sb.append('"').append(getName()).append('"').toString(); }
/** * Converts a Restlet-EntityTag to a JAX-RS-EntityTag * * @param restletEntityTag * the Restlet-EntityTag to convert. * @return The corresponding JAX-RS-Entity-Tag */ public static EntityTag toJaxRsEntityTag(Tag restletEntityTag) { return (restletEntityTag == null) ? null : new EntityTag(restletEntityTag.getName(), restletEntityTag.isWeak()); }
/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @param checkWeakness * the equality test takes care or not of the weakness. * * @return True if both tags are equal. */ public boolean equals(final Object object, boolean checkWeakness) { boolean result = (object != null) && (object instanceof Tag); if (result) { final Tag that = (Tag) object; if (checkWeakness) { result = (that.isWeak() == isWeak()); } if (result) { if (getName() == null) { result = (that.getName() == null); } else { result = getName().equals(that.getName()); } } } return result; }
/** * Indicates if both tags are equal. * * @param object * The object to compare to. * @param checkWeakness * The equality test takes care or not of the weakness. * * @return True if both tags are equal. */ public boolean equals(final Object object, boolean checkWeakness) { boolean result = (object != null) && (object instanceof Tag); if (result) { final Tag that = (Tag) object; if (checkWeakness) { result = (that.isWeak() == isWeak()); } if (result) { if (getName() == null) { result = (that.getName() == null); } else { result = getName().equals(that.getName()); } } } return result; }