List of usage examples for java.util Objects equals
public static boolean equals(Object a, Object b)
From source file:io.confluent.kafkarest.entities.ConsumerRecord.java
@Override public boolean equals(Object o) { if (this == o) { return true; }//from ww w.j a v a2s. c o m if (o == null || getClass() != o.getClass()) { return false; } ConsumerRecord<?, ?> that = (ConsumerRecord<?, ?>) o; return partition == that.partition && offset == that.offset && Objects.equals(topic, that.topic) && Objects.equals(key, that.key) && Objects.equals(value, that.value); }
From source file:com.autodesk.client.model.CreateRef.java
@Override public boolean equals(java.lang.Object o) { if (this == o) { return true; }/*from w w w .ja va2 s.co m*/ if (o == null || getClass() != o.getClass()) { return false; } CreateRef createRef = (CreateRef) o; return Objects.equals(this.jsonapi, createRef.jsonapi) && Objects.equals(this.data, createRef.data); }
From source file:com.compomics.cell_coord.parser.impl.TSVFileParser.java
@Override public Sample parseTrackFile(File trackFile) throws FileParserException { // create a new sample object -- watch out to set the relationships! Sample sample = new Sample(trackFile.getName()); // initialize an empty list of tracks List<Track> list = new ArrayList<>(); CSVParser tsvFileParser;//from w w w . j av a 2 s .c o m FileReader fileReader; CSVFormat csvFileFormat = CSVFormat.TDF.withHeader(FILE_HEADER_MAPPING); try { // initialize the file reader fileReader = new FileReader(trackFile); //initialize CSVParser object tsvFileParser = new CSVParser(fileReader, csvFileFormat); // get the csv records List<CSVRecord> csvRecords = tsvFileParser.getRecords(); Track currentTrack = null; List<TrackSpot> currentTrackPointList = new ArrayList<>(); Long currentId = 0L; //Read the CSV file records starting from the second record to skip the header for (int i = 1; i < csvRecords.size(); i++) { CSVRecord cSVRecord = csvRecords.get(i); // get the fields Long trackid = Long.parseLong(cSVRecord.get(TRACK_ID)); if (!Objects.equals(currentId, trackid)) { currentTrack = new Track(); currentTrack.setTrackid(trackid); list.add(currentTrack); currentId = trackid; currentTrackPointList = new ArrayList<>(); } // create new Track Spot object Long spotid = Long.parseLong(cSVRecord.get(SPOT_ID)); double x = Double.parseDouble(cSVRecord.get(X_COORD)); double y = Double.parseDouble(cSVRecord.get(Y_COORD)); double time = Double.parseDouble(cSVRecord.get(TIME)); TrackSpot trackSpot = new TrackSpot(spotid, x, y, time, currentTrack); currentTrackPointList.add(trackSpot); currentTrack.setTrackSpots(currentTrackPointList); currentTrack.setSample(sample); } } catch (IOException ex) { LOG.error(ex.getMessage(), ex); } catch (NumberFormatException ex) { LOG.error(ex.getMessage(), ex); throw new FileParserException( "It seems like a line does not contain a number!\nPlease check your files!"); } sample.setTracks(list); return sample; }
From source file:com.vmware.photon.controller.model.adapters.vsphere.ovf.OvfImporterService.java
private Runnable createImportTask(ImportOvfRequest req, Operation patch) { return () -> { URI ovfUri;//from ww w .ja va2 s . com HttpClient client = OvfRetriever.newInsecureClient(); OvfRetriever retriever = new OvfRetriever(client); OvfParser parser = new OvfParser(); Document doc; try { ovfUri = retriever.downloadIfOva(req.ovfUri); doc = parser.retrieveDescriptor(ovfUri); } catch (Exception e) { patch.fail(e); return; } CustomProperties.of(req.template).put(OvfParser.PROP_OVF_URI, ovfUri); if (!Objects.equals(ovfUri, req.ovfUri)) { // this is an ova archive, store original OVA uri CustomProperties.of(req.template).put(OvfParser.PROP_OVF_ARCHIVE_URI, req.ovfUri); } List<ComputeDescription> ovfDescriptions = parser.parse(doc, req.template); Stream<Operation> opStream = ovfDescriptions.stream().map(desc -> Operation .createPost(getHost(), ComputeDescriptionService.FACTORY_LINK).setBodyNoCloning(desc)); OperationJoin join = OperationJoin.create().setOperations(opStream).setCompletion((os, es) -> { if (es != null && !es.isEmpty()) { patch.fail(es.values().iterator().next()); } else { patch.complete(); } }); join.sendWith(this); }; }
From source file:com.autodesk.client.model.MeshGeomBoundingBox.java
@Override public boolean equals(java.lang.Object o) { if (this == o) { return true; }/* w w w . ja v a 2 s .co m*/ if (o == null || getClass() != o.getClass()) { return false; } MeshGeomBoundingBox meshGeomBoundingBox = (MeshGeomBoundingBox) o; return Objects.equals(this.max, meshGeomBoundingBox.max) && Objects.equals(this.min, meshGeomBoundingBox.min); }
From source file:br.com.senac.Bean.UsuarioBean.java
@Override public boolean equals(Object obj) { if (obj == null) { return false; }/*w w w .j a va 2 s .c o m*/ if (getClass() != obj.getClass()) { return false; } final UsuarioBean other = (UsuarioBean) obj; if (!Objects.equals(this.usuario, other.usuario)) { return false; } return true; }
From source file:io.curly.advisor.command.ReviewHystrixCommands.java
@HystrixCommand public void save(ReviewEntity reviewEntity, User user) { if (reviewEntity.getId() != null) { final Review fromDb = repository.findByIdAndOwner(reviewEntity.getId(), user.getId()); if (fromDb != null && Objects.equals(fromDb.getOwner(), user.getId())) { Review review = reviewEntity.toNewReview(user); repository.save(review);// w w w . ja v a2 s. c o m } } else { repository.save(reviewEntity.toNewReview(user)); } }
From source file:br.com.esign.logistics.core.Place.java
@Override public boolean equals(Object obj) { if (obj == null) { return false; }/* w w w . j a va 2s . com*/ if (getClass() != obj.getClass()) { return false; } final Place other = (Place) obj; return Objects.equals(this.name, other.name); }
From source file:com.compomics.cell_coord.parser.impl.CSVFileParser.java
@Override public Sample parseTrackFile(File trackFile) throws FileParserException { // create a new sample object -- watch out to set the relationships! Sample sample = new Sample(trackFile.getName()); // initialize an empty list of tracks List<Track> list = new ArrayList<>(); CSVParser csvFileParser;/*from ww w. java 2s . c o m*/ FileReader fileReader; CSVFormat csvFileFormat = CSVFormat.DEFAULT.withHeader(FILE_HEADER_MAPPING); try { // initialize the file reader fileReader = new FileReader(trackFile); //initialize CSVParser object csvFileParser = new CSVParser(fileReader, csvFileFormat); // get the csv records List<CSVRecord> csvRecords = csvFileParser.getRecords(); Track currentTrack = null; List<TrackSpot> currentTrackPointList = new ArrayList<>(); Long currentId = 0L; // read the CSV file records starting from the second record to skip the header for (int i = 1; i < csvRecords.size(); i++) { CSVRecord cSVRecord = csvRecords.get(i); // get the fields Long trackid = Long.parseLong(cSVRecord.get(TRACK_ID)); if (!Objects.equals(currentId, trackid)) { currentTrack = new Track(); currentTrack.setTrackid(trackid); list.add(currentTrack); currentId = trackid; currentTrackPointList = new ArrayList<>(); } // create new Track Spot object Long spotid = Long.parseLong(cSVRecord.get(SPOT_ID)); double x = Double.parseDouble(cSVRecord.get(X_COORD)); double y = Double.parseDouble(cSVRecord.get(Y_COORD)); double time = Double.parseDouble(cSVRecord.get(TIME)); TrackSpot trackSpot = new TrackSpot(spotid, x, y, time, currentTrack); currentTrackPointList.add(trackSpot); currentTrack.setTrackSpots(currentTrackPointList); currentTrack.setSample(sample); } } catch (IOException ex) { LOG.error(ex.getMessage(), ex); } catch (NumberFormatException ex) { LOG.error(ex.getMessage(), ex); throw new FileParserException( "It seems like a line does not contain a number!\nPlease check your files!"); } // set the tracks for the sample sample.setTracks(list); return sample; }
From source file:com.pinterest.deployservice.common.ChangeFeedJob.java
private static String getConfigChangeMessage(Object ori, Object cur) { if (ori.getClass() != cur.getClass()) return null; List<String> results = new ArrayList<>(); try {/*from w ww. j av a2 s.c o m*/ if (ori instanceof List) { // Process list of custom object and others (e.g. List<String>) List<?> originalList = (List<?>) ori; List<?> currentList = (List<?>) cur; for (int i = 0; i < Math.max(originalList.size(), currentList.size()); i++) { Object originalItem = i < originalList.size() ? originalList.get(i) : null; Object currentItem = i < currentList.size() ? currentList.get(i) : null; if (!Objects.equals(originalItem, currentItem)) { Object temp = originalItem != null ? originalItem : currentItem; if (temp.getClass().getName().startsWith("com.pinterest")) { results.add(String.format("%-40s %-40s %-40s%n", i, toStringRepresentation(originalItem), toStringRepresentation(currentItem))); } else { results.add(String.format("%-40s %-40s %-40s%n", i, originalItem, currentItem)); } } } } else if (ori instanceof Map) { // Process Map (e.g. Map<String, String>) Map<?, ?> originalMap = (Map<?, ?>) ori; Map<?, ?> currentMap = (Map<?, ?>) cur; Set<String> keys = new HashSet<>(); originalMap.keySet().stream().forEach(key -> keys.add((String) key)); currentMap.keySet().stream().forEach(key -> keys.add((String) key)); for (String key : keys) { Object originalItem = originalMap.get(key); Object currentItem = currentMap.get(key); if (!Objects.equals(originalItem, currentItem)) { results.add(String.format("%-40s %-40s %-40s%n", key, originalItem, currentItem)); } } } else { // Process other objects (e.g. custom object bean) Field[] fields = ori.getClass().getDeclaredFields(); for (Field field : fields) { field.setAccessible(true); Object oriObj = field.get(ori); Object curObj = field.get(cur); if (!Objects.equals(oriObj, curObj)) { if (oriObj instanceof List) { results.add(String.format("%-40s %-40s %-40s%n", field.getName(), toStringRepresentation(oriObj), toStringRepresentation(curObj))); } else { results.add(String.format("%-40s %-40s %-40s%n", field.getName(), oriObj, curObj)); } } } } } catch (Exception e) { LOG.error("Failed to get config message.", e); } if (results.isEmpty()) { return null; } StringBuilder resultBuilder = new StringBuilder(); resultBuilder.append(String.format("%n%-40s %-40s %-40s%n", "Name", "Original Value", "Current Value")); results.stream().forEach(resultBuilder::append); return resultBuilder.toString(); }