/** * Indicates if the current variant is equal to the given variant. * * @param other * The other variant. * @return True if the current variant includes the other. */ @Override public boolean equals(Object other) { if (other == this) { return true; } if (!(other instanceof Variant)) { return false; } Variant that = (Variant) other; return Objects.equals(getCharacterSet(), that.getCharacterSet()) && Objects.equals(getMediaType(), that.getMediaType()) && getLanguages().equals(that.getLanguages()) && getEncodings().equals(that.getEncodings()) && Objects.equals(getLocationRef(), that.getLocationRef()); }
@Override protected Representation get() throws ResourceException { // Content negotiation has been disabled // The variant that may need to meet the request conditions List<Variant> variants = getVariants(Method.GET); if ((variants == null) || (variants.isEmpty())) { // Resource not found throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND); } if (variants.size() == 1) { return (Representation) variants.get(0); } ReferenceList variantRefs = new ReferenceList(); for (Variant variant : variants) { if (variant.getLocationRef() != null) { variantRefs.add(variant.getLocationRef()); } else { getLogger() .warning( "A resource with multiple variants should provide a location for each variant when content negotiation is turned off"); } } if (!variantRefs.isEmpty()) { // Return the list of variants setStatus(Status.REDIRECTION_MULTIPLE_CHOICES); return variantRefs.getTextRepresentation(); } throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND); }
result = ((getLocationRef() == null) && (otherVariant.getLocationRef() == null) || (getLocationRef() != null) && getLocationRef().equals( otherVariant.getLocationRef()));
/** * Constructor from a variant. * * @param variant * The variant to copy. * @param modificationDate * The modification date. * @param tag * The tag. */ public RepresentationInfo(Variant variant, Date modificationDate, Tag tag) { setCharacterSet(variant.getCharacterSet()); setLocationRef(variant.getLocationRef()); setLanguages(variant.getLanguages()); setMediaType(variant.getMediaType()); setModificationDate(modificationDate); setTag(tag); }
/** * Constructor from a variant. * * @param variant * The variant to copy. * @param modificationDate * The modification date. * @param tag * The tag. */ public RepresentationInfo(Variant variant, Date modificationDate, Tag tag) { setCharacterSet(variant.getCharacterSet()); setEncodings(variant.getEncodings()); setLocationRef(variant.getLocationRef()); setLanguages(variant.getLanguages()); setMediaType(variant.getMediaType()); setModificationDate(modificationDate); setTag(tag); }
/** * Constructor from a variant. * * @param variant * The variant to copy. * @param modificationDate * The modification date. * @param tag * The tag. */ public Representation(Variant variant, Date modificationDate, Tag tag) { setCharacterSet(variant.getCharacterSet()); setEncodings(variant.getEncodings()); setLocationRef(variant.getLocationRef()); setLanguages(variant.getLanguages()); setMediaType(variant.getMediaType()); setModificationDate(modificationDate); setTag(tag); }