/** * Shallow copy of everything, except for the attribute list and the temporary attributes. A new * list of the attributes is created for both, but the attributes themselves are copied by * reference. This should be safe because callers should never modify a mutable value returned by * any of the get() methods anyway. * * @return a shallow copy of the GATKSAMRecord */ @Override public Object clone() { try { final GATKSAMRecord clone = (GATKSAMRecord) super.clone(); if (temporaryAttributes != null) { clone.temporaryAttributes = new HashMap<>(); for (Object attribute : temporaryAttributes.keySet()) clone.setTemporaryAttribute(attribute, temporaryAttributes.get(attribute)); } return clone; } catch (final CloneNotSupportedException e) { throw new RuntimeException(e); } }