Skip to content

Commit

Permalink
Rename Types -> Type
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Sep 17, 2018
1 parent 0f97463 commit 75ed2a3
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
Expand Up @@ -618,7 +618,7 @@ public void testIndexSeekRangeWithExistsBySpatialArray() throws Exception
public void testExactMatchOnRandomCompositeValues() throws Exception public void testExactMatchOnRandomCompositeValues() throws Exception
{ {
// given // given
List<RandomValues.Types> types = testSuite.supportedValueTypes(); List<RandomValues.Type> types = testSuite.supportedValueTypes();
List<IndexEntryUpdate<?>> updates = new ArrayList<>(); List<IndexEntryUpdate<?>> updates = new ArrayList<>();
Set<ValueTuple> duplicateChecker = new HashSet<>(); Set<ValueTuple> duplicateChecker = new HashSet<>();
for ( long id = 0; id < 10_000; id++ ) for ( long id = 0; id < 10_000; id++ )
Expand Down
Expand Up @@ -57,7 +57,7 @@ public CompositeRandomizedIndexAccessorCompatibility( IndexProviderCompatibility
public void testExactMatchOnRandomCompositeValues() throws Exception public void testExactMatchOnRandomCompositeValues() throws Exception
{ {
// given // given
List<RandomValues.Types> types = testSuite.supportedValueTypes(); List<RandomValues.Type> types = testSuite.supportedValueTypes();
Collections.shuffle( types, random.random() ); Collections.shuffle( types, random.random() );
types = types.subList( 0, random.nextInt( 2, types.size() ) ); types = types.subList( 0, random.nextInt( 2, types.size() ) );
List<IndexEntryUpdate<?>> updates = new ArrayList<>(); List<IndexEntryUpdate<?>> updates = new ArrayList<>();
Expand Down
Expand Up @@ -98,15 +98,15 @@ public boolean supportFullValuePrecisionForNumbers()
return true; return true;
} }


public List<RandomValues.Types> supportedValueTypes() public List<RandomValues.Type> supportedValueTypes()
{ {
List<RandomValues.Types> types = new ArrayList<>( Arrays.asList( RandomValues.Types.values() ) ); List<RandomValues.Type> types = new ArrayList<>( Arrays.asList( RandomValues.Type.values() ) );
if ( !supportsSpatial() ) if ( !supportsSpatial() )
{ {
types.remove( RandomValues.Types.CARTESIAN_POINT ); types.remove( RandomValues.Type.CARTESIAN_POINT );
types.remove( RandomValues.Types.CARTESIAN_POINT_3D ); types.remove( RandomValues.Type.CARTESIAN_POINT_3D );
types.remove( RandomValues.Types.GEOGRAPHIC_POINT ); types.remove( RandomValues.Type.GEOGRAPHIC_POINT );
types.remove( RandomValues.Types.GEOGRAPHIC_POINT_3D ); types.remove( RandomValues.Type.GEOGRAPHIC_POINT_3D );
} }
return types; return types;
} }
Expand Down
Expand Up @@ -56,7 +56,7 @@ public SimpleRandomizedIndexAccessorCompatibility( IndexProviderCompatibilityTes
public void testExactMatchOnRandomValues() throws Exception public void testExactMatchOnRandomValues() throws Exception
{ {
// given // given
List<RandomValues.Types> types = testSuite.supportedValueTypes(); List<RandomValues.Type> types = testSuite.supportedValueTypes();
Collections.shuffle( types, random.random() ); Collections.shuffle( types, random.random() );
types = types.subList( 0, random.nextInt( 2, types.size() ) ); types = types.subList( 0, random.nextInt( 2, types.size() ) );


Expand Down
Expand Up @@ -281,7 +281,7 @@ public Value nextValue()
return randoms.nextValue(); return randoms.nextValue();
} }


public Value nextValue( RandomValues.Types type ) public Value nextValue( RandomValues.Type type )
{ {
return randoms.nextValueOfType( type ); return randoms.nextValueOfType( type );
} }
Expand Down
Expand Up @@ -74,7 +74,7 @@
*/ */
public class RandomValues public class RandomValues
{ {
public enum Types public enum Type
{ {
BOOLEAN( ValueGroup.NUMBER, BooleanValue.class ), BOOLEAN( ValueGroup.NUMBER, BooleanValue.class ),
BYTE( ValueGroup.NUMBER, ByteValue.class ), BYTE( ValueGroup.NUMBER, ByteValue.class ),
Expand Down Expand Up @@ -125,23 +125,23 @@ public enum Types
public final Class<? extends Value> valueClass; public final Class<? extends Value> valueClass;
public final boolean arrayType; public final boolean arrayType;


Types( ValueGroup valueGroup, Class<? extends Value> valueClass ) Type( ValueGroup valueGroup, Class<? extends Value> valueClass )
{ {
this( valueGroup, valueClass, false ); this( valueGroup, valueClass, false );
} }


Types( ValueGroup valueGroup, Class<? extends Value> valueClass, boolean arrayType ) Type( ValueGroup valueGroup, Class<? extends Value> valueClass, boolean arrayType )
{ {
this.valueGroup = valueGroup; this.valueGroup = valueGroup;
this.valueClass = valueClass; this.valueClass = valueClass;
this.arrayType = arrayType; this.arrayType = arrayType;
} }


static Types[] arrayTypes() static Type[] arrayTypes()
{ {
return Arrays.stream( Types.values() ) return Arrays.stream( Type.values() )
.filter( t -> t.arrayType ) .filter( t -> t.arrayType )
.toArray( Types[]::new ); .toArray( Type[]::new );
} }
} }


Expand Down Expand Up @@ -194,8 +194,8 @@ public int maxCodePoint()
private static final int MAX_ASCII_CODE_POINT = 0x7F; private static final int MAX_ASCII_CODE_POINT = 0x7F;
public static final int MAX_BMP_CODE_POINT = 0xFFFF; public static final int MAX_BMP_CODE_POINT = 0xFFFF;
public static final Configuration DEFAULT_CONFIGURATION = new Default(); public static final Configuration DEFAULT_CONFIGURATION = new Default();
private static final Types[] ALL_TYPES = Types.values(); private static final Type[] ALL_TYPES = Type.values();
private static final Types[] ARRAY_TYPES = Types.arrayTypes(); private static final Type[] ARRAY_TYPES = Type.arrayTypes();
private static final long NANOS_PER_SECOND = 1_000_000_000L; private static final long NANOS_PER_SECOND = 1_000_000_000L;


private final Generator generator; private final Generator generator;
Expand Down Expand Up @@ -287,27 +287,27 @@ public Value nextValue()
* *
* @see RandomValues * @see RandomValues
*/ */
public Value nextValueOfTypes( Types... types ) public Value nextValueOfTypes( Type... types )
{ {
return nextValueOfType( among( types ) ); return nextValueOfType( among( types ) );
} }


/** /**
* Create an array containing all value types, excluding provided types. * Create an array containing all value types, excluding provided types.
*/ */
public Types[] excluding( Types... types ) public Type[] excluding( Type... types )
{ {
return Arrays.stream( Types.values() ) return Arrays.stream( Type.values() )
.filter( t -> !ArrayUtils.contains( types, t ) ) .filter( t -> !ArrayUtils.contains( types, t ) )
.toArray( Types[]::new ); .toArray( Type[]::new );
} }


/** /**
* Returns the next {@link Value} of provided type. * Returns the next {@link Value} of provided type.
* *
* @see RandomValues * @see RandomValues
*/ */
public Value nextValueOfType( Types type ) public Value nextValueOfType( Type type )
{ {
switch ( type ) switch ( type )
{ {
Expand Down
Expand Up @@ -281,10 +281,10 @@ public void nextValue()
@Test @Test
public void nextValueOfTypes() public void nextValueOfTypes()
{ {
RandomValues.Types[] allTypes = RandomValues.Types.values(); RandomValues.Type[] allTypes = RandomValues.Type.values();
RandomValues.Types[] including = randomValues.selection( allTypes, 1, allTypes.length, false ); RandomValues.Type[] including = randomValues.selection( allTypes, 1, allTypes.length, false );
HashSet<Class<? extends AnyValue>> seen = new HashSet<>(); HashSet<Class<? extends AnyValue>> seen = new HashSet<>();
for ( RandomValues.Types type : including ) for ( RandomValues.Type type : including )
{ {
seen.add( type.valueClass ); seen.add( type.valueClass );
} }
Expand All @@ -300,10 +300,10 @@ public void nextValueOfTypes()
@Test @Test
public void excluding() public void excluding()
{ {
RandomValues.Types[] allTypes = RandomValues.Types.values(); RandomValues.Type[] allTypes = RandomValues.Type.values();
RandomValues.Types[] excluding = randomValues.selection( allTypes, 1, allTypes.length, false ); RandomValues.Type[] excluding = randomValues.selection( allTypes, 1, allTypes.length, false );
RandomValues.Types[] including = randomValues.excluding( excluding ); RandomValues.Type[] including = randomValues.excluding( excluding );
for ( RandomValues.Types excludedType : excluding ) for ( RandomValues.Type excludedType : excluding )
{ {
if ( ArrayUtils.contains( including, excludedType ) ) if ( ArrayUtils.contains( including, excludedType ) )
{ {
Expand All @@ -324,9 +324,9 @@ public void nextBasicMultilingualPlaneTextValue()
} }
} }


private void assertValueAmongTypes( RandomValues.Types[] types, Value value ) private void assertValueAmongTypes( RandomValues.Type[] types, Value value )
{ {
for ( RandomValues.Types type : types ) for ( RandomValues.Type type : types )
{ {
if ( type.valueClass.isAssignableFrom( value.getClass() ) ) if ( type.valueClass.isAssignableFrom( value.getClass() ) )
{ {
Expand Down

0 comments on commit 75ed2a3

Please sign in to comment.