Skip to content

Commit

Permalink
HSEARCH-3487 Make ScaledNumberIndexFieldTypeContext more generic
Browse files Browse the repository at this point in the history
So that it could be used not just for BigDecimal fields
  • Loading branch information
fax4ever committed May 23, 2019
1 parent bacab9a commit a2ee81d
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

class ElasticsearchBigDecimalIndexFieldTypeContext
extends AbstractElasticsearchScalarFieldTypeContext<ElasticsearchBigDecimalIndexFieldTypeContext, BigDecimal>
implements ScaledNumberIndexFieldTypeContext<ElasticsearchBigDecimalIndexFieldTypeContext> {
implements ScaledNumberIndexFieldTypeContext<ElasticsearchBigDecimalIndexFieldTypeContext, BigDecimal> {

private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public StandardIndexFieldTypeContext<?, GeoPoint> asGeoPoint() {
}

@Override
public ScaledNumberIndexFieldTypeContext<?> asBigDecimal() {
public ScaledNumberIndexFieldTypeContext<?, BigDecimal> asBigDecimal() {
return new ElasticsearchBigDecimalIndexFieldTypeContext( this, typeDefaultsProvider );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class LuceneBigDecimalIndexFieldTypeContext
extends AbstractLuceneStandardIndexFieldTypeContext<LuceneBigDecimalIndexFieldTypeContext, BigDecimal>
implements ScaledNumberIndexFieldTypeContext<LuceneBigDecimalIndexFieldTypeContext> {
implements ScaledNumberIndexFieldTypeContext<LuceneBigDecimalIndexFieldTypeContext, BigDecimal> {

private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public StandardIndexFieldTypeContext<?, GeoPoint> asGeoPoint() {
}

@Override
public ScaledNumberIndexFieldTypeContext<?> asBigDecimal() {
public ScaledNumberIndexFieldTypeContext<?, BigDecimal> asBigDecimal() {
return new LuceneBigDecimalIndexFieldTypeContext( this, typeDefaultsProvider );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.hibernate.search.engine.backend.types.dsl;

import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
Expand Down Expand Up @@ -65,7 +66,7 @@ public interface IndexFieldTypeFactoryContext {

StandardIndexFieldTypeContext<?, GeoPoint> asGeoPoint();

ScaledNumberIndexFieldTypeContext<?> asBigDecimal();
ScaledNumberIndexFieldTypeContext<?, BigDecimal> asBigDecimal();

// TODO HSEARCH-3487 add asBigInteger() method here

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
*/
package org.hibernate.search.engine.backend.types.dsl;

import java.math.BigDecimal;

/**
* @param <S> The type of this context.
* @param <S> The concrete type of this context.
* @param <F> The type of field values.
*/
public interface ScaledNumberIndexFieldTypeContext<S extends ScaledNumberIndexFieldTypeContext<? extends S>>
extends StandardIndexFieldTypeContext<S, BigDecimal> {
public interface ScaledNumberIndexFieldTypeContext<S extends ScaledNumberIndexFieldTypeContext<? extends S, F>, F>
extends StandardIndexFieldTypeContext<S, F> {

S decimalScale(int decimalScale);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.hibernate.search.util.common.logging.impl.LoggerFactory;

public class PropertyScaledNumberFieldMappingContextImpl
extends AbstractPropertyNotFullTextFieldMappingContext<PropertyScaledNumberFieldMappingContext, ScaledNumberIndexFieldTypeContext<?>>
extends AbstractPropertyNotFullTextFieldMappingContext<PropertyScaledNumberFieldMappingContext, ScaledNumberIndexFieldTypeContext<?, ?>>
implements PropertyScaledNumberFieldMappingContext {

private static final Log log = LoggerFactory.make( Log.class, MethodHandles.lookup() );
Expand All @@ -36,10 +36,10 @@ public PropertyScaledNumberFieldMappingContext decimalScale(int decimalScale) {
return thisAsS();
}

private static ScaledNumberIndexFieldTypeContext<?> convertFieldTypedContext(
private static ScaledNumberIndexFieldTypeContext<?, ?> convertFieldTypedContext(
StandardIndexFieldTypeContext<?,?> context) {
if ( context instanceof ScaledNumberIndexFieldTypeContext ) {
return (ScaledNumberIndexFieldTypeContext<?>) context;
return (ScaledNumberIndexFieldTypeContext<?, ?>) context;
}
else {
throw log.invalidFieldEncodingForScaledNumberFieldMapping(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public StandardIndexFieldTypeContext<?, GeoPoint> asGeoPoint() {
}

@Override
public ScaledNumberIndexFieldTypeContext<?> asBigDecimal() {
public ScaledNumberIndexFieldTypeContext<?, BigDecimal> asBigDecimal() {
return new StubScaledNumberIndexFieldTypeContext( defaultsProvider );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class StubScaledNumberIndexFieldTypeContext
extends AbstractStubStandardIndexFieldTypeContext<StubScaledNumberIndexFieldTypeContext, BigDecimal>
implements ScaledNumberIndexFieldTypeContext<StubScaledNumberIndexFieldTypeContext> {
implements ScaledNumberIndexFieldTypeContext<StubScaledNumberIndexFieldTypeContext, BigDecimal> {

public StubScaledNumberIndexFieldTypeContext(IndexFieldTypeDefaultsProvider defaultsProvider) {
super( BigDecimal.class );
Expand Down

0 comments on commit a2ee81d

Please sign in to comment.