From e6ee9059319e9ac5bbf1ddb5549a37d3f4c6e480 Mon Sep 17 00:00:00 2001 From: Alexander Reelsen Date: Thu, 15 Dec 2016 11:33:36 +0100 Subject: [PATCH] Watcher: Remove unused class Original commit: elastic/x-pack-elasticsearch@ecd48b7914ebfc0d496c5c1adf4add199b09b48e --- .../support/SearchRequestEquivalence.java | 49 ------------------- 1 file changed, 49 deletions(-) delete mode 100644 elasticsearch/src/main/java/org/elasticsearch/xpack/watcher/support/SearchRequestEquivalence.java diff --git a/elasticsearch/src/main/java/org/elasticsearch/xpack/watcher/support/SearchRequestEquivalence.java b/elasticsearch/src/main/java/org/elasticsearch/xpack/watcher/support/SearchRequestEquivalence.java deleted file mode 100644 index cc063d56920..00000000000 --- a/elasticsearch/src/main/java/org/elasticsearch/xpack/watcher/support/SearchRequestEquivalence.java +++ /dev/null @@ -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); - } - } -}