Make a non-access modifier local variables. (#980)

This commit is contained in:
Arturo Bernal 2023-03-14 13:54:07 +01:00 committed by GitHub
parent 4d7e6ffac8
commit 4e8d9d39f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 21 deletions

View File

@ -147,14 +147,14 @@ public void test_toStringIncludeNullCollection() {
@Test
public void test_toStringDefaultBehavior() {
ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
final ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
final String toString = builder.toString();
this.validateAllFieldsPresent(toString);
}
@Test
public void test_toStringSetIncludeAndExcludeWithoutIntersection() {
ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
final ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
builder.setExcludeFieldNames(FIELDS[1], FIELDS[4]);
builder.setIncludeFieldNames(FIELDS_TO_SHOW);
final String toString = builder.toString();
@ -163,7 +163,7 @@ public void test_toStringSetIncludeAndExcludeWithoutIntersection() {
@Test
public void test_toStringSetIncludeAndExcludeWithIntersection() {
ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
final ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
builder.setExcludeFieldNames(FIELDS[1], FIELDS[4]);
builder.setIncludeFieldNames(FIELDS[0], FIELDS[1]);
Assertions.assertThrows(IllegalStateException.class, () -> {
@ -173,7 +173,7 @@ public void test_toStringSetIncludeAndExcludeWithIntersection() {
@Test
public void test_toStringSetIncludeWithMultipleNullFields() {
ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
final ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
builder.setExcludeFieldNames(FIELDS[1], FIELDS[4]);
builder.setIncludeFieldNames(null, null, null);
final String toString = builder.toString();
@ -182,7 +182,7 @@ public void test_toStringSetIncludeWithMultipleNullFields() {
@Test
public void test_toStringSetIncludeWithArrayWithMultipleNullFields() {
ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
final ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
builder.setExcludeFieldNames(new String[] {FIELDS[1], FIELDS[4]});
builder.setIncludeFieldNames(new String[] {null, null, null});
final String toString = builder.toString();
@ -191,7 +191,7 @@ public void test_toStringSetIncludeWithArrayWithMultipleNullFields() {
@Test
public void test_toStringSetIncludeAndExcludeWithRandomFieldsWithIntersection() {
ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
final ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
builder.setExcludeFieldNames(FIELDS[1], "random1");
builder.setIncludeFieldNames("random1");
Assertions.assertThrows(IllegalStateException.class, () -> {
@ -201,38 +201,38 @@ public void test_toStringSetIncludeAndExcludeWithRandomFieldsWithIntersection()
@Test
public void test_toStringSetIncludeAndExcludeWithRandomFieldsWithoutIntersection() {
ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
final ReflectionToStringBuilder builder = new ReflectionToStringBuilder(new TestFeature());
builder.setExcludeFieldNames(FIELDS[1], "random1");
builder.setIncludeFieldNames("random2", FIELDS[2]);
final String toString = builder.toString();
this.validateIncludeFieldsPresent(toString, new String[]{FIELDS[2]}, new String[]{VALUES[2]});
}
private void validateAllFieldsPresent(String toString) {
private void validateAllFieldsPresent(final String toString) {
validateIncludeFieldsPresent(toString, FIELDS, VALUES);
}
private void validateIncludeFieldsPresent(final String toString, final String[] fieldsToShow, final String[] valuesToShow) {
for (String includeField : fieldsToShow) {
for (final String includeField : fieldsToShow) {
assertTrue(toString.indexOf(includeField) > 0);
}
for (String includeValue : valuesToShow) {
for (final String includeValue : valuesToShow) {
assertTrue(toString.indexOf(includeValue) > 0);
}
this.validateNonIncludeFieldsAbsent(toString, fieldsToShow, valuesToShow);
}
private void validateNonIncludeFieldsAbsent(String toString, String[] IncludeFields, String[] IncludeFieldsValues) {
String[] nonIncludeFields = ArrayUtils.removeElements(FIELDS.clone(), IncludeFields);
String[] nonIncludeFieldsValues = ArrayUtils.removeElements(VALUES.clone(), IncludeFieldsValues);
private void validateNonIncludeFieldsAbsent(final String toString, final String[] IncludeFields, final String[] IncludeFieldsValues) {
final String[] nonIncludeFields = ArrayUtils.removeElements(FIELDS.clone(), IncludeFields);
final String[] nonIncludeFieldsValues = ArrayUtils.removeElements(VALUES.clone(), IncludeFieldsValues);
for (String nonIncludeField : nonIncludeFields) {
for (final String nonIncludeField : nonIncludeFields) {
assertEquals(ArrayUtils.INDEX_NOT_FOUND, toString.indexOf(nonIncludeField));
}
for (String nonIncludeValue : nonIncludeFieldsValues) {
for (final String nonIncludeValue : nonIncludeFieldsValues) {
assertEquals(ArrayUtils.INDEX_NOT_FOUND, toString.indexOf(nonIncludeValue));
}
}

View File

@ -27,14 +27,14 @@
public class PrintAtomicVsMutable {
public static void main(String[] args) {
MutableInt mInt = new MutableInt();
final MutableInt mInt = new MutableInt();
final int max = 100_000_000;
System.out.println("MutableInt " + DurationUtils.of(() -> {
for (int i = 0; i < max; i++) {
mInt.incrementAndGet();
}
}));
AtomicInteger aInt = new AtomicInteger();
final AtomicInteger aInt = new AtomicInteger();
System.out.println("AtomicInteger " + DurationUtils.of(() -> {
for (int i = 0; i < max; i++) {
aInt.incrementAndGet();

View File

@ -82,8 +82,8 @@ protected void baseRoundTest(final Date roundedUpDate, final Date roundedDownDat
//Calendar-initiations
final Calendar roundedUpCalendar;
Calendar roundedDownCalendar;
Calendar lastRoundDownCalendar;
final Calendar roundedDownCalendar;
final Calendar lastRoundDownCalendar;
final Calendar firstRoundUpCalendar;
roundedDownCalendar = Calendar.getInstance();
roundedUpCalendar = Calendar.getInstance();
@ -132,7 +132,7 @@ protected void baseTruncateTest(final Date truncatedDate, final Date lastTruncat
//Calendar-initiations
final Calendar truncatedCalendar;
Calendar lastTruncateCalendar;
final Calendar lastTruncateCalendar;
final Calendar nextTruncateCalendar;
truncatedCalendar = Calendar.getInstance();
lastTruncateCalendar = Calendar.getInstance();
@ -256,7 +256,7 @@ public void testRoundAmPm() throws Exception {
public void testRoundDate() throws Exception {
final int calendarField = Calendar.DATE;
final Date roundedUpDate;
Date roundedDownDate;
final Date roundedDownDate;
final Date lastRoundedDownDate;
final Date minDate;
final Date maxDate;