/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * <div class="note"><b>Note on properties validation:</b> * This constructor does not verify the property values of the given metadata (e.g. whether it contains * unexpected negative values). This is because invalid metadata exist in practice, and verifying their * validity in this copy constructor is often too late. Note that this is not the only hole, as invalid * metadata instances can also be obtained by unmarshalling an invalid XML document. * </div> * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(Medium) */ public DefaultMedium(final Medium object) { super(object); if (object != null) { name = object.getName(); densities = copyCollection(object.getDensities(), Double.class); densityUnits = object.getDensityUnits(); volumes = object.getVolumes(); mediumFormats = copyCollection(object.getMediumFormats(), MediumFormat.class); mediumNote = object.getMediumNote(); if (object instanceof DefaultMedium) { identifiers = singleton(((DefaultMedium) object).getIdentifier(), Identifier.class); } } }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * <div class="note"><b>Note on properties validation:</b> * This constructor does not verify the property values of the given metadata (e.g. whether it contains * unexpected negative values). This is because invalid metadata exist in practice, and verifying their * validity in this copy constructor is often too late. Note that this is not the only hole, as invalid * metadata instances can also be obtained by unmarshalling an invalid XML document. * </div> * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(Medium) */ public DefaultMedium(final Medium object) { super(object); if (object != null) { name = object.getName(); densities = copyCollection(object.getDensities(), Double.class); densityUnits = object.getDensityUnits(); volumes = object.getVolumes(); mediumFormats = copyCollection(object.getMediumFormats(), MediumFormat.class); mediumNote = object.getMediumNote(); if (object instanceof DefaultMedium) { identifiers = singleton(((DefaultMedium) object).getIdentifier(), Identifier.class); } } }