• 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/BeanUtils.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;
17

18
import static com.expediagroup.transformer.validator.Validator.notNull;
19

20
import java.util.function.Function;
21

22
import com.expediagroup.beans.conversion.Converter;
23
import com.expediagroup.beans.conversion.ConverterImpl;
24
import com.expediagroup.beans.transformer.BeanTransformer;
25
import com.expediagroup.beans.transformer.TransformerImpl;
26
import com.expediagroup.transformer.validator.Validator;
27
import com.expediagroup.transformer.validator.ValidatorImpl;
28

29
/**
30
 * Set of Bean utilities.
31
 */
32
public class BeanUtils {
2✔
33

34
    /**
35
     * Returns a function that transforms an object T in an object K.
36
     * @param targetClass the destination object class
37
     * @param <T> the Source object type
38
     * @param <K> the target object type
39
     * @return a function that copies of the source object into the destination object
40
     * @throws IllegalArgumentException if any parameter is invalid
41
     */
42
    public static <T, K> Function<T, K> getTransformer(final Class<K> targetClass) {
43
        return fromBean -> new TransformerImpl().transform(fromBean, targetClass);
2✔
44
    }
45

46
    /**
47
     * Returns a function that transforms an object T in an object K.
48
     * @param beanTransformer the transformer to be used.
49
     * @param targetClass the destination object
50
     * @param <T> the Source object type
51
     * @param <K> the target object type
52
     * @return a function that copies of the source object into the destination object
53
     * @throws IllegalArgumentException if any parameter is invalid
54
     */
55
    public static <T, K> Function<T, K> getTransformer(final BeanTransformer beanTransformer, final Class<K> targetClass) {
56
        notNull(beanTransformer, "beanTransformer cannot be null!");
2✔
57
        return fromBean -> beanTransformer.transform(fromBean, targetClass);
2✔
58
    }
59

60
    /**
61
     * Returns a Bean Transformer.
62
     * @return a {@link BeanTransformer} instance.
63
     */
64
    public final BeanTransformer getTransformer() {
65
        return new TransformerImpl();
2✔
66
    }
67

68
    /**
69
     * Returns a Bean Validator.
70
     * @return a Bean Validator instance.
71
     */
72
    public final Validator getValidator() {
73
        return new ValidatorImpl();
2✔
74
    }
75

76
    /**
77
     * Returns a primitive type converter.
78
     * @return a {@link Converter} instance.
79
     */
80
    public final Converter getPrimitiveTypeConverter() {
81
        return new ConverterImpl();
2✔
82
    }
83

84
}
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