Watcher: Remove unused class

Original commit: elastic/x-pack-elasticsearch@ecd48b7914
This commit is contained in:
Alexander Reelsen 2016-12-15 11:33:36 +01:00
parent 6d4d599f91
commit e6ee905931
1 changed files with 0 additions and 49 deletions

View File

@ -1,49 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
package org.elasticsearch.xpack.watcher.support;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.BytesStreamOutput;
import java.util.Arrays;
import static org.elasticsearch.xpack.watcher.support.Exceptions.illegalState;
/**
* The only true way today to compare search request object (outside of core) is to
* serialize it and compare the serialized output. this is heavy obviously, but luckily we
* don't compare search requests in normal runtime... we only do it in the tests. The is here basically
* due to the lack of equals/hashcode support in SearchRequest in core.
*/
public final class SearchRequestEquivalence {
public static final SearchRequestEquivalence INSTANCE = new SearchRequestEquivalence();
private SearchRequestEquivalence() {
}
public boolean equivalent(@Nullable SearchRequest a, @Nullable SearchRequest b) {
return a == b ? true : (a != null && b != null ? this.doEquivalent(a, b) : false);
}
protected boolean doEquivalent(SearchRequest r1, SearchRequest r2) {
try {
BytesStreamOutput output1 = new BytesStreamOutput();
r1.writeTo(output1);
byte[] bytes1 = BytesReference.toBytes(output1.bytes());
output1.reset();
r2.writeTo(output1);
byte[] bytes2 = BytesReference.toBytes(output1.bytes());
return Arrays.equals(bytes1, bytes2);
} catch (Exception e) {
throw illegalState("could not compare search requests", e);
}
}
}