@Test public void testEquals() { String includeFields = "field1,field2"; String excludeFields = "field3,field4"; String sortBy = "field5"; int offset = 4; int limit = 5; NeutralQuery.SortOrder sortOrderAscending = NeutralQuery.SortOrder.ascending; NeutralQuery.SortOrder sortOrderDescending = NeutralQuery.SortOrder.descending; NeutralQuery neutralQuery1 = new NeutralQuery(); neutralQuery1.setIncludeFieldString(includeFields); neutralQuery1.setExcludeFieldString(excludeFields); neutralQuery1.setLimit(limit); neutralQuery1.setOffset(offset); neutralQuery1.setSortBy(sortBy); neutralQuery1.setSortOrder(sortOrderAscending); NeutralQuery neutralQuery2 = new NeutralQuery(neutralQuery1); assertTrue(neutralQuery1.equals(neutralQuery2)); assertTrue(neutralQuery1 != neutralQuery2); neutralQuery1.setIncludeFieldString(""); assertFalse(neutralQuery1.equals(neutralQuery2)); neutralQuery2.setIncludeFieldString(""); assertTrue(neutralQuery1.equals(neutralQuery2)); neutralQuery1.setExcludeFieldString(""); assertFalse(neutralQuery1.equals(neutralQuery2)); neutralQuery2.setExcludeFieldString(""); assertTrue(neutralQuery1.equals(neutralQuery2)); neutralQuery1.setLimit(7); assertFalse(neutralQuery1.equals(neutralQuery2)); neutralQuery2.setLimit(7); assertTrue(neutralQuery1.equals(neutralQuery2)); neutralQuery1.setOffset(9); assertFalse(neutralQuery1.equals(neutralQuery2)); neutralQuery2.setOffset(9); assertTrue(neutralQuery1.equals(neutralQuery2)); neutralQuery1.setSortBy(""); assertFalse(neutralQuery1.equals(neutralQuery2)); neutralQuery2.setSortBy(""); assertTrue(neutralQuery1.equals(neutralQuery2)); neutralQuery1.setSortOrder(sortOrderDescending); assertFalse(neutralQuery1.equals(neutralQuery2)); neutralQuery2.setSortOrder(sortOrderDescending); assertTrue(neutralQuery1.equals(neutralQuery2)); neutralQuery1.addCriteria(new NeutralCriteria("x=1")); neutralQuery2.addCriteria(new NeutralCriteria("x=2")); assertFalse(neutralQuery1.equals(neutralQuery2)); neutralQuery1.addCriteria(new NeutralCriteria("x=2")); assertFalse(neutralQuery1.equals(neutralQuery2)); neutralQuery2.prependCriteria(new NeutralCriteria("x=1")); assertTrue(neutralQuery1.equals(neutralQuery2)); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } NeutralQuery other = (NeutralQuery) obj; if (excludeFields == null) { if (other.excludeFields != null) { return false; } } else if (!excludeFields.equals(other.excludeFields)) { return false; } if (includeFields == null) { if (other.includeFields != null) { return false; } } else if (!includeFields.equals(other.includeFields)) { return false; } if (limit != other.limit) { return false; } if (offset != other.offset) { return false; } if (orQueries == null) { if (other.orQueries != null) { return false; } } else if (!orQueries.equals(other.orQueries)) { return false; } if (queryCriteria == null) { if (other.queryCriteria != null) { return false; } } else if (!queryCriteria.equals(other.queryCriteria)) { return false; } if (sortBy == null) { if (other.sortBy != null) { return false; } } else if (!sortBy.equals(other.sortBy)) { return false; } if (sortOrder != other.sortOrder) { return false; } return true; }
NeutralQuery { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } NeutralQuery other = (NeutralQuery) obj; if (excludeFields == null) { if (other.excludeFields != null) { return false; } } else if (!excludeFields.equals(other.excludeFields)) { return false; } if (includeFields == null) { if (other.includeFields != null) { return false; } } else if (!includeFields.equals(other.includeFields)) { return false; } if (limit != other.limit) { return false; } if (offset != other.offset) { return false; } if (orQueries == null) { if (other.orQueries != null) { return false; } } else if (!orQueries.equals(other.orQueries)) { return false; } if (queryCriteria == null) { if (other.queryCriteria != null) { return false; } } else if (!queryCriteria.equals(other.queryCriteria)) { return false; } if (sortBy == null) { if (other.sortBy != null) { return false; } } else if (!sortBy.equals(other.sortBy)) { return false; } if (sortOrder != other.sortOrder) { return false; } return true; } }
NeutralQuery { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } NeutralQuery other = (NeutralQuery) obj; if (excludeFields == null) { if (other.excludeFields != null) { return false; } } else if (!excludeFields.equals(other.excludeFields)) { return false; } if (includeFields == null) { if (other.includeFields != null) { return false; } } else if (!includeFields.equals(other.includeFields)) { return false; } if (limit != other.limit) { return false; } if (offset != other.offset) { return false; } if (orQueries == null) { if (other.orQueries != null) { return false; } } else if (!orQueries.equals(other.orQueries)) { return false; } if (queryCriteria == null) { if (other.queryCriteria != null) { return false; } } else if (!queryCriteria.equals(other.queryCriteria)) { return false; } if (sortBy == null) { if (other.sortBy != null) { return false; } } else if (!sortBy.equals(other.sortBy)) { return false; } if (sortOrder != other.sortOrder) { return false; } return true; } NeutralQuery();  NeutralQuery(int limit);  NeutralQuery(NeutralQuery otherNeutralQuery);  NeutralQuery(NeutralCriteria neutralCriteria); }
NeutralQuery { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } NeutralQuery other = (NeutralQuery) obj; if (excludeFields == null) { if (other.excludeFields != null) { return false; } } else if (!excludeFields.equals(other.excludeFields)) { return false; } if (includeFields == null) { if (other.includeFields != null) { return false; } } else if (!includeFields.equals(other.includeFields)) { return false; } if (limit != other.limit) { return false; } if (offset != other.offset) { return false; } if (orQueries == null) { if (other.orQueries != null) { return false; } } else if (!orQueries.equals(other.orQueries)) { return false; } if (queryCriteria == null) { if (other.queryCriteria != null) { return false; } } else if (!queryCriteria.equals(other.queryCriteria)) { return false; } if (sortBy == null) { if (other.sortBy != null) { return false; } } else if (!sortBy.equals(other.sortBy)) { return false; } if (sortOrder != other.sortOrder) { return false; } return true; } NeutralQuery();  NeutralQuery(int limit);  NeutralQuery(NeutralQuery otherNeutralQuery);  NeutralQuery(NeutralCriteria neutralCriteria); List<String> getEmbeddedFields(); void setEmbeddedFields(List<String> embeddedFields); @Override int hashCode(); @Override boolean equals(Object obj); NeutralQuery addOrQuery(NeutralQuery orQuery); List<NeutralQuery> getOrQueries(); final NeutralQuery addCriteria(NeutralCriteria criteria); NeutralQuery prependCriteria(NeutralCriteria criteria); List<NeutralCriteria> getCriteria(); List<String> getIncludeFields(); NeutralQuery setIncludeFields(List<String> includeFields); List<String> getExcludeFields(); NeutralQuery setExcludeFields(List<String> excludeFields); boolean removeCriteria(NeutralCriteria criteria); @Deprecated String getIncludeFieldString(); @Deprecated String getExcludeFieldString(); int getOffset(); int getLimit(); String getSortBy(); SortOrder getSortOrder(); NeutralQuery setLimit(int newLimit); NeutralQuery setOffset(int newOffset); NeutralQuery setIncludeFieldString(String newIncludeFields); NeutralQuery setExcludeFieldString(String newExcludeFields); NeutralQuery setEmbeddedFieldString(String newEmbeddedFields); NeutralQuery setSortBy(String newSortBy); NeutralQuery setSortOrder(SortOrder newSortOrder); NeutralQuery setQueryCriteria(List<NeutralCriteria> newQueryCriteria); void setCountOnly(boolean value); boolean getCountOnly(); boolean isCountOnly(); @Override String toString(); }
NeutralQuery { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } NeutralQuery other = (NeutralQuery) obj; if (excludeFields == null) { if (other.excludeFields != null) { return false; } } else if (!excludeFields.equals(other.excludeFields)) { return false; } if (includeFields == null) { if (other.includeFields != null) { return false; } } else if (!includeFields.equals(other.includeFields)) { return false; } if (limit != other.limit) { return false; } if (offset != other.offset) { return false; } if (orQueries == null) { if (other.orQueries != null) { return false; } } else if (!orQueries.equals(other.orQueries)) { return false; } if (queryCriteria == null) { if (other.queryCriteria != null) { return false; } } else if (!queryCriteria.equals(other.queryCriteria)) { return false; } if (sortBy == null) { if (other.sortBy != null) { return false; } } else if (!sortBy.equals(other.sortBy)) { return false; } if (sortOrder != other.sortOrder) { return false; } return true; } NeutralQuery();  NeutralQuery(int limit);  NeutralQuery(NeutralQuery otherNeutralQuery);  NeutralQuery(NeutralCriteria neutralCriteria); List<String> getEmbeddedFields(); void setEmbeddedFields(List<String> embeddedFields); @Override int hashCode(); @Override boolean equals(Object obj); NeutralQuery addOrQuery(NeutralQuery orQuery); List<NeutralQuery> getOrQueries(); final NeutralQuery addCriteria(NeutralCriteria criteria); NeutralQuery prependCriteria(NeutralCriteria criteria); List<NeutralCriteria> getCriteria(); List<String> getIncludeFields(); NeutralQuery setIncludeFields(List<String> includeFields); List<String> getExcludeFields(); NeutralQuery setExcludeFields(List<String> excludeFields); boolean removeCriteria(NeutralCriteria criteria); @Deprecated String getIncludeFieldString(); @Deprecated String getExcludeFieldString(); int getOffset(); int getLimit(); String getSortBy(); SortOrder getSortOrder(); NeutralQuery setLimit(int newLimit); NeutralQuery setOffset(int newOffset); NeutralQuery setIncludeFieldString(String newIncludeFields); NeutralQuery setExcludeFieldString(String newExcludeFields); NeutralQuery setEmbeddedFieldString(String newEmbeddedFields); NeutralQuery setSortBy(String newSortBy); NeutralQuery setSortOrder(SortOrder newSortOrder); NeutralQuery setQueryCriteria(List<NeutralCriteria> newQueryCriteria); void setCountOnly(boolean value); boolean getCountOnly(); boolean isCountOnly(); @Override String toString();  }