@Override public int hashCode() { if (getId() != InstrumentModel.UNSAVED_ID) { return getId().intValue(); } else { final int PRIME = 37; int hashcode = -1; if (getPlatformType() != null) hashcode = PRIME * hashcode + getPlatformType().hashCode(); if (getDescription() != null) hashcode = PRIME * hashcode + getDescription().hashCode(); return hashcode; } }
/** * Equivalency is based on id if set, otherwise on name, description and creation date. */ @Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof InstrumentModel)) return false; InstrumentModel them = (InstrumentModel) obj; // If not saved, then compare resolved actual objects. Otherwise // just compare IDs. if (getId() == InstrumentModel.UNSAVED_ID || them.getId() == InstrumentModel.UNSAVED_ID) { return getPlatformType().equals(them.getPlatformType()) && getDescription().equals(them.getDescription()); } else { return getId().longValue() == them.getId().longValue(); } }
if (experiment.getInstrumentModel() != null && experiment.getInstrumentModel().getPlatformType().getSraName() != null) { Element platform = xml.getOwnerDocument().createElementNS(null, "PLATFORM"); Element type = xml.getOwnerDocument().createElementNS(null, experiment.getInstrumentModel().getPlatformType().getSraName()); platform.appendChild(type);
public static InstrumentModelDto asDto(@Nonnull InstrumentModel from) { InstrumentModelDto dto = new InstrumentModelDto(); dto.setId(from.getId()); dto.setPlatformType(from.getPlatformType().name()); dto.setDescription(from.getDescription()); dto.setAlias(from.getAlias()); dto.setNumContainers(from.getNumContainers()); dto.setInstrumentType(from.getInstrumentType().name()); if (from.getPositions() != null) { dto.setPositions(from.getPositions().stream().map(InstrumentPosition::getAlias).collect(Collectors.toList())); } return dto; }
dto.setPlatformType(from.getSequencer().getInstrumentModel().getPlatformType().getKey()); } else { dto.setPlatformType("");