Skip to content

Commit d5d029f

Browse files
authored
Minor changes (#12)
1 parent 385128c commit d5d029f

File tree

13 files changed

+20
-34
lines changed

13 files changed

+20
-34
lines changed

easy-random-bean-validation/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.github.dvgaba</groupId>
88
<artifactId>easy-random</artifactId>
9-
<version>6.1.0</version>
9+
<version>6.1.1</version>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
1212
<artifactId>easy-random-bean-validation</artifactId>

easy-random-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.github.dvgaba</groupId>
88
<artifactId>easy-random</artifactId>
9-
<version>6.1.0</version>
9+
<version>6.1.1</version>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
1212
<artifactId>easy-random-core</artifactId>

easy-random-core/src/main/java/org/jeasy/random/RandomizationContext.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
*/
2424
package org.jeasy.random;
2525

26-
import static java.util.stream.Collectors.toList;
27-
2826
import java.lang.reflect.Field;
2927
import java.util.*;
3028
import org.jeasy.random.api.RandomizerContext;
@@ -108,7 +106,7 @@ private List<String> getStackedFieldNames() {
108106
}
109107

110108
private List<String> toLowerCase(final List<String> strings) {
111-
return strings.stream().map(String::toLowerCase).collect(toList());
109+
return strings.stream().map(String::toLowerCase).toList();
112110
}
113111

114112
void setRandomizedObject(Object randomizedObject) {

easy-random-core/src/main/java/org/jeasy/random/util/ReflectionUtils.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import static java.lang.String.format;
2727
import static java.util.Arrays.asList;
2828
import static java.util.Locale.ENGLISH;
29-
import static java.util.stream.Collectors.toList;
3029
import static org.jeasy.random.util.ConversionUtils.convertArguments;
3130

3231
import java.lang.annotation.Annotation;
@@ -203,7 +202,7 @@ public static boolean isPrimitiveFieldWithDefaultValue(final Object object, fina
203202
if (fieldValue == null) {
204203
return false;
205204
}
206-
if (fieldType.equals(boolean.class) && (boolean) fieldValue == false) {
205+
if (fieldType.equals(boolean.class) && !((boolean) fieldValue)) {
207206
return true;
208207
}
209208
if (fieldType.equals(byte.class) && (byte) fieldValue == (byte) 0) {
@@ -374,11 +373,7 @@ public static boolean isJdkBuiltIn(final Class<?> type) {
374373
* @return true if the type is parameterized, false otherwise
375374
*/
376375
public static boolean isParameterizedType(final Type type) {
377-
return (
378-
type != null &&
379-
type instanceof ParameterizedType &&
380-
((ParameterizedType) type).getActualTypeArguments().length > 0
381-
);
376+
return (type instanceof ParameterizedType && ((ParameterizedType) type).getActualTypeArguments().length > 0);
382377
}
383378

384379
/**
@@ -420,8 +415,8 @@ public static <T> List<Class<?>> getPublicConcreteSubTypesOf(final Class<T> type
420415
* @return a list of types having the same parameterized types as the given type
421416
*/
422417
public static List<Class<?>> filterSameParameterizedTypes(final List<Class<?>> types, final Type type) {
423-
if (type instanceof ParameterizedType) {
424-
Type[] fieldArugmentTypes = ((ParameterizedType) type).getActualTypeArguments();
418+
if (type instanceof ParameterizedType parameterizedType) {
419+
Type[] fieldArugmentTypes = parameterizedType.getActualTypeArguments();
425420
List<Class<?>> typesWithSameParameterizedTypes = new ArrayList<>();
426421
for (Class<?> currentConcreteType : types) {
427422
List<Type[]> actualTypeArguments = getActualTypeArgumentsOfGenericInterfaces(currentConcreteType);
@@ -430,7 +425,7 @@ public static List<Class<?>> filterSameParameterizedTypes(final List<Class<?>> t
430425
.stream()
431426
.filter(currentTypeArguments -> Arrays.equals(fieldArugmentTypes, currentTypeArguments))
432427
.map(currentTypeArguments -> currentConcreteType)
433-
.collect(toList())
428+
.toList()
434429
);
435430
}
436431
return typesWithSameParameterizedTypes;
@@ -598,8 +593,8 @@ private static List<Type[]> getActualTypeArgumentsOfGenericInterfaces(final Clas
598593
List<Type[]> actualTypeArguments = new ArrayList<>();
599594
Type[] genericInterfaceTypes = type.getGenericInterfaces();
600595
for (Type currentGenericInterfaceType : genericInterfaceTypes) {
601-
if (currentGenericInterfaceType instanceof ParameterizedType) {
602-
actualTypeArguments.add(((ParameterizedType) currentGenericInterfaceType).getActualTypeArguments());
596+
if (currentGenericInterfaceType instanceof ParameterizedType parameterizedType) {
597+
actualTypeArguments.add((parameterizedType).getActualTypeArguments());
603598
}
604599
}
605600
return actualTypeArguments;

easy-random-protobuf/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.github.dvgaba</groupId>
88
<artifactId>easy-random</artifactId>
9-
<version>6.1.0</version>
9+
<version>6.1.1</version>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
1212
<artifactId>easy-random-protobuf</artifactId>

easy-random-protobuf/src/main/java/org/jeasy/random/protobuf/ProtobufExclusionPolicy.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
public class ProtobufExclusionPolicy extends DefaultExclusionPolicy {
1111

12+
@Override
1213
public boolean shouldBeExcluded(final Field field, final RandomizerContext context, Object object) {
1314
if (!(object instanceof FieldDescriptor)) {
1415
throw new IllegalArgumentException("3rd parameter must be of FieldDescriptor");

easy-random-protobuf/src/main/java/org/jeasy/random/protobuf/ProtobufMessageBuilderRandomizer.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
public class ProtobufMessageBuilderRandomizer implements ContextAwareRandomizer<Builder> {
3535

3636
private final ProtobufMessageRandomizer protobufMessageRandomizer;
37-
private RandomizerContext context;
3837

3938
public ProtobufMessageBuilderRandomizer(
4039
Class<Message.Builder> messageBuilderClass,
@@ -65,7 +64,6 @@ public String toString() {
6564

6665
@Override
6766
public void setRandomizerContext(RandomizerContext context) {
68-
this.context = context;
6967
protobufMessageRandomizer.setRandomizerContext(context);
7068
}
7169
}

easy-random-protobuf/src/main/java/org/jeasy/random/protobuf/ProtobufMessageRandomizer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import java.util.EnumMap;
4747
import java.util.List;
4848
import java.util.function.BiFunction;
49-
import java.util.stream.Collectors;
5049
import org.jeasy.random.EasyRandom;
5150
import org.jeasy.random.EasyRandomParameters;
5251
import org.jeasy.random.api.ContextAwareRandomizer;
@@ -117,7 +116,7 @@ public Message getRandomValue() {
117116
.getFields()
118117
.stream()
119118
.filter(field -> field.getContainingOneof() == null)
120-
.collect(Collectors.toList());
119+
.toList();
121120
for (FieldDescriptor fieldDescriptor : plainFields) {
122121
populateField(fieldDescriptor, builder);
123122
}

easy-random-protobuf/src/main/java/org/jeasy/random/protobuf/ProtobufPredicates.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
public class ProtobufPredicates {
2020

21-
private static EnumMap protoToJavaTypeMap = new EnumMap(FieldDescriptor.Type.class);
21+
private static EnumMap<Type, Class<?>> protoToJavaTypeMap = new EnumMap<>(FieldDescriptor.Type.class);
2222

2323
static {
2424
protoToJavaTypeMap.put(Type.INT32, Int32Value.class);
@@ -37,11 +37,8 @@ public class ProtobufPredicates {
3737
}
3838

3939
public static BiPredicate<Field, Object> named(final String name) {
40-
System.out.println(name);
4140
final Pattern pattern = Pattern.compile(name + "_");
42-
return (field, fieldDescriptor) -> {
43-
return pattern.matcher(field.getName()).matches();
44-
};
41+
return (field, fieldDescriptor) -> pattern.matcher(field.getName()).matches();
4542
}
4643

4744
public static BiPredicate<Field, Object> ofProtobufType(Class<?> type) {
@@ -58,8 +55,6 @@ public static BiPredicate<Field, Object> ofProtobufType(Class<?> type) {
5855
}
5956

6057
public static Predicate<Class<?>> ofType(Class<?> type) {
61-
return clz -> {
62-
return clz.equals(type);
63-
};
58+
return clz -> clz.equals(type);
6459
}
6560
}

easy-random-protobuf/src/test/java/org/jeasy/random/protobuf/Protobuf2MessageBuilderGenerationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ void shouldGenerateTheSameValueForTheSameSeed() {
108108
assertThat(embeddedMessage.getEnumField()).isEqualTo(Proto2Enum.THIRD_VALUE);
109109
});
110110
assertThat(protoBuilderInstance.getOneofFieldCase().getNumber())
111-
.isNotEqualTo(Proto2Message.OneofFieldCase.ONEOFFIELD_NOT_SET);
111+
.isNotEqualTo(Proto2Message.OneofFieldCase.ONEOFFIELD_NOT_SET.getNumber());
112112
assertThat(protoBuilderInstance.getMapFieldMap())
113113
.hasSize(4)
114114
.containsEntry(

easy-random-protobuf/src/test/java/org/jeasy/random/protobuf/Protobuf2MessageGenerationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void shouldGenerateTheSameValueForTheSameSeed() {
104104
assertThat(embeddedMessage.getEnumField()).isEqualTo(Proto2Enum.THIRD_VALUE);
105105
});
106106
assertThat(protoInstance.getOneofFieldCase().getNumber())
107-
.isNotEqualTo(Proto2Message.OneofFieldCase.ONEOFFIELD_NOT_SET);
107+
.isNotEqualTo(Proto2Message.OneofFieldCase.ONEOFFIELD_NOT_SET.getNumber());
108108
assertThat(protoInstance.getMapFieldMap())
109109
.hasSize(4)
110110
.containsEntry(

easy-random-randomizers/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>io.github.dvgaba</groupId>
88
<artifactId>easy-random</artifactId>
9-
<version>6.1.0</version>
9+
<version>6.1.1</version>
1010
</parent>
1111
<modelVersion>4.0.0</modelVersion>
1212
<artifactId>easy-random-randomizers</artifactId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<modelVersion>4.0.0</modelVersion>
1212
<groupId>io.github.dvgaba</groupId>
1313
<artifactId>easy-random</artifactId>
14-
<version>6.1.0</version>
14+
<version>6.1.1</version>
1515
<packaging>pom</packaging>
1616

1717
<build>

0 commit comments

Comments
 (0)