• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ExpediaGroup / bull / #926

03 Apr 2024 02:09PM CUT coverage: 100.0%. Remained the same
#926

Pull #486

Fabio Borriello
Trigger notification
Pull Request #486: Bump org.jacoco:jacoco-maven-plugin from 0.8.11 to 0.8.12

1198 of 1198 relevant lines covered (100.0%)

1.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/bull-bean-transformer/src/main/java/com/expediagroup/beans/populator/ArrayPopulator.java
1
/**
2
 * Copyright (C) 2019-2023 Expedia, Inc.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 * http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package com.expediagroup.beans.populator;
17

18
import static java.util.Arrays.stream;
19

20
import java.lang.reflect.Field;
21

22
import com.expediagroup.beans.transformer.BeanTransformer;
23

24
/**
25
 * Populator for primitive types array.
26
 */
27
class ArrayPopulator extends Populator<Object> implements ICollectionPopulator<Object> {
28

29
    /**
30
     * Default constructor.
31
     * @param beanTransformer the bean transformer containing the field name mapping and transformation functions
32
     */
33
    ArrayPopulator(final BeanTransformer beanTransformer) {
34
        super(beanTransformer);
2✔
35
    }
2✔
36

37
    /**
38
     * {@inheritDoc}
39
     */
40
    @Override
41
    public Object getPopulatedObject(final Field field, final Object fieldValue) {
42
        return getPopulatedObject(field.getType(), reflectionUtils.getArrayType(field), fieldValue, null);
2✔
43
    }
44

45
    /**
46
     * {@inheritDoc}
47
     */
48
    @Override
49
    public Object getPopulatedObject(final Class<?> fieldType, final Class<?> genericFieldType, final Object fieldValue, final Class<?> nestedGenericClass) {
50
        final Object res;
51
        if (classUtils.isPrimitiveTypeArray(fieldValue.getClass()) || classUtils.isPrimitiveOrSpecialType(genericFieldType)) {
2✔
52
            res = fieldValue;
2✔
53
        } else {
54
            res = stream((Object[]) fieldValue)
2✔
55
                    //.parallel()
56
                    .map(o -> classUtils.isPrimitiveOrSpecialType(o.getClass()) ? o : transform(o, genericFieldType)).toArray();
2✔
57
        }
58
        return res;
2✔
59
    }
60
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc