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

ExpediaGroup / bull / #865

09 Jan 2024 03:40PM CUT coverage: 100.0%. Remained the same
#865

Pull #461

Fabio Borriello
Trigger notification
Pull Request #461: Bump org.slf4j:slf4j-api from 2.0.10 to 2.0.11

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/PopulatorFactory.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.Optional.empty;
19
import static java.util.Optional.of;
20

21
import static lombok.AccessLevel.PRIVATE;
22

23
import java.util.Collection;
24
import java.util.Map;
25
import java.util.Optional;
26

27
import com.expediagroup.beans.transformer.BeanTransformer;
28

29
import lombok.NoArgsConstructor;
30

31
/**
32
 * Creates a {@link Populator} instance for the given class.
33
 */
34
@NoArgsConstructor(access = PRIVATE)
35
public final class PopulatorFactory {
36
    /**
37
     * Creates an instance of the populator object based on the given class.
38
     * @param <O> the generic type of the contained object in the destination object
39
     * @param <T> the generic type of the contained object in the source object
40
     * @param destObjectClass the destination object class
41
     * @param sourceObjectClass the source object class
42
     * @param transformer the bean transformer containing the field name mapping and transformation functions
43
     * @return the populator instance
44
     */
45
    public static <O, T> Optional<Populator> getPopulator(final Class<O> destObjectClass, final Class<T> sourceObjectClass, final BeanTransformer transformer) {
46
        Optional<Populator> populator = empty();
2✔
47
        if (destObjectClass.isArray()) {
2✔
48
            populator = of(new ArrayPopulator(transformer));
2✔
49
        } else if (Collection.class.isAssignableFrom(destObjectClass)) {
2✔
50
            populator = of(new CollectionPopulator(transformer));
2✔
51
        } else if (Map.class.isAssignableFrom(destObjectClass)) {
2✔
52
            populator = of(new MapPopulator(transformer));
2✔
53
        } else if (Optional.class == sourceObjectClass || Optional.class == destObjectClass) {
2✔
54
            populator = of(new OptionalPopulator(transformer));
2✔
55
        }
56
        return populator;
2✔
57
    }
58
}
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