Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HSEARCH-2519 Reduce code duplication in DefaultElasticsearchSchemaVal…
…idator The volume of code does not change much, but it feels a bit cleaner. This commit can be removed without impacting features.
- Loading branch information
Showing
7 changed files
with
404 additions
and
437 deletions.
There are no files selected for viewing
580 changes: 288 additions & 292 deletions
580
...a/org/hibernate/search/elasticsearch/schema/impl/DefaultElasticsearchSchemaValidator.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...rc/main/java/org/hibernate/search/elasticsearch/schema/impl/ValidationContextElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.elasticsearch.schema.impl; | ||
|
||
import java.util.Objects; | ||
|
||
final class ValidationContextElement { | ||
|
||
private final ValidationContextType type; | ||
private final String name; | ||
|
||
public ValidationContextElement(ValidationContextType type, String name) { | ||
super(); | ||
this.type = type; | ||
this.name = name; | ||
} | ||
|
||
public ValidationContextType getType() { | ||
return type; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new StringBuilder() | ||
.append( type ) | ||
.append( "[" ) | ||
.append( name ) | ||
.append( "]" ) | ||
.toString(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if ( obj != null && getClass().equals( obj.getClass() ) ) { | ||
ValidationContextElement other = (ValidationContextElement) obj; | ||
return Objects.equals( type, other.type ) | ||
&& Objects.equals( name, other.name ); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + Objects.hashCode( type ); | ||
result = prime * result + Objects.hashCode( name ); | ||
return result; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...h/src/main/java/org/hibernate/search/elasticsearch/schema/impl/ValidationContextType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Hibernate Search, full-text search for your domain model | ||
* | ||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later | ||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. | ||
*/ | ||
package org.hibernate.search.elasticsearch.schema.impl; | ||
|
||
enum ValidationContextType { | ||
|
||
INDEX, | ||
MAPPING, | ||
MAPPING_PROPERTY, | ||
MAPPING_PROPERTY_FIELD, | ||
ANALYZER, | ||
CHAR_FILTER, | ||
TOKENIZER, | ||
TOKEN_FILTER; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters