@Test public void testEquality() { List<ParseGeoPoint> points = new ArrayList<>(); points.add(new ParseGeoPoint(0, 0)); points.add(new ParseGeoPoint(0, 1)); points.add(new ParseGeoPoint(1, 1)); points.add(new ParseGeoPoint(1, 0)); List<ParseGeoPoint> diff = new ArrayList<>(); diff.add(new ParseGeoPoint(0, 0)); diff.add(new ParseGeoPoint(0, 10)); diff.add(new ParseGeoPoint(10, 10)); diff.add(new ParseGeoPoint(10, 0)); diff.add(new ParseGeoPoint(0, 0)); ParsePolygon polygonA = new ParsePolygon(points); ParsePolygon polygonB = new ParsePolygon(points); ParsePolygon polygonC = new ParsePolygon(diff); assertTrue(polygonA.equals(polygonB)); assertTrue(polygonA.equals(polygonA)); assertTrue(polygonB.equals(polygonA)); assertFalse(polygonA.equals(null)); assertFalse(polygonA.equals(true)); assertFalse(polygonA.equals(polygonC)); }
@Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof ParsePolygon)) { return false; } if (obj == this) { return true; } ParsePolygon other = (ParsePolygon) obj; if (coordinates.size() != other.getCoordinates().size()) { return false; } boolean isEqual = true; for (int i = 0; i < coordinates.size(); i += 1) { if (coordinates.get(i).getLatitude() != other.getCoordinates().get(i).getLatitude() || coordinates.get(i).getLongitude() != other.getCoordinates().get(i).getLongitude()) { isEqual = false; break; } } return isEqual; }
ParsePolygon implements Parcelable { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof ParsePolygon)) { return false; } if (obj == this) { return true; } ParsePolygon other = (ParsePolygon) obj; if (coordinates.size() != other.getCoordinates().size()) { return false; } boolean isEqual = true; for (int i = 0; i < coordinates.size(); i += 1) { if (coordinates.get(i).getLatitude() != other.getCoordinates().get(i).getLatitude() || coordinates.get(i).getLongitude() != other.getCoordinates().get(i).getLongitude()) { isEqual = false; break; } } return isEqual; } }
ParsePolygon implements Parcelable { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof ParsePolygon)) { return false; } if (obj == this) { return true; } ParsePolygon other = (ParsePolygon) obj; if (coordinates.size() != other.getCoordinates().size()) { return false; } boolean isEqual = true; for (int i = 0; i < coordinates.size(); i += 1) { if (coordinates.get(i).getLatitude() != other.getCoordinates().get(i).getLatitude() || coordinates.get(i).getLongitude() != other.getCoordinates().get(i).getLongitude()) { isEqual = false; break; } } return isEqual; } ParsePolygon(List<ParseGeoPoint> coords);  ParsePolygon(ParsePolygon polygon); protected  ParsePolygon(Parcel source);   ParsePolygon(Parcel source, ParseParcelDecoder decoder); }
ParsePolygon implements Parcelable { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof ParsePolygon)) { return false; } if (obj == this) { return true; } ParsePolygon other = (ParsePolygon) obj; if (coordinates.size() != other.getCoordinates().size()) { return false; } boolean isEqual = true; for (int i = 0; i < coordinates.size(); i += 1) { if (coordinates.get(i).getLatitude() != other.getCoordinates().get(i).getLatitude() || coordinates.get(i).getLongitude() != other.getCoordinates().get(i).getLongitude()) { isEqual = false; break; } } return isEqual; } ParsePolygon(List<ParseGeoPoint> coords);  ParsePolygon(ParsePolygon polygon); protected  ParsePolygon(Parcel source);   ParsePolygon(Parcel source, ParseParcelDecoder decoder); List<ParseGeoPoint> getCoordinates(); void setCoordinates(List<ParseGeoPoint> coords); boolean containsPoint(ParseGeoPoint point); @Override boolean equals(Object obj); @Override String toString(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); }
ParsePolygon implements Parcelable { @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof ParsePolygon)) { return false; } if (obj == this) { return true; } ParsePolygon other = (ParsePolygon) obj; if (coordinates.size() != other.getCoordinates().size()) { return false; } boolean isEqual = true; for (int i = 0; i < coordinates.size(); i += 1) { if (coordinates.get(i).getLatitude() != other.getCoordinates().get(i).getLatitude() || coordinates.get(i).getLongitude() != other.getCoordinates().get(i).getLongitude()) { isEqual = false; break; } } return isEqual; } ParsePolygon(List<ParseGeoPoint> coords);  ParsePolygon(ParsePolygon polygon); protected  ParsePolygon(Parcel source);   ParsePolygon(Parcel source, ParseParcelDecoder decoder); List<ParseGeoPoint> getCoordinates(); void setCoordinates(List<ParseGeoPoint> coords); boolean containsPoint(ParseGeoPoint point); @Override boolean equals(Object obj); @Override String toString(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); final static Creator<ParsePolygon> CREATOR; }