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

mybatis / mybatis-3 / #2972

pending completion
#2972

Pull #2794

github

web-flow
Merge d6dc7c239 into 77c9ac027
Pull Request #2794: [ci] Formatting

135 of 135 new or added lines in 32 files covered. (100.0%)

9413 of 10782 relevant lines covered (87.3%)

0.87 hits per line

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

90.91
/src/main/java/org/apache/ibatis/reflection/property/PropertyNamer.java
1
/*
2
 *    Copyright 2009-2023 the original author or authors.
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
 *       https://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 org.apache.ibatis.reflection.property;
17

18
import java.util.Locale;
19

20
import org.apache.ibatis.reflection.ReflectionException;
21

22
/**
23
 * @author Clinton Begin
24
 */
25
public final class PropertyNamer {
26

27
  private PropertyNamer() {
28
    // Prevent Instantiation of Static Class
29
  }
30

31
  public static String methodToProperty(String name) {
32
    if (name.startsWith("is")) {
1✔
33
      name = name.substring(2);
1✔
34
    } else if (name.startsWith("get") || name.startsWith("set")) {
1✔
35
      name = name.substring(3);
1✔
36
    } else {
37
      throw new ReflectionException(
×
38
          "Error parsing property name '" + name + "'.  Didn't start with 'is', 'get' or 'set'.");
39
    }
40

41
    if (name.length() == 1 || (name.length() > 1 && !Character.isUpperCase(name.charAt(1)))) {
1✔
42
      name = name.substring(0, 1).toLowerCase(Locale.ENGLISH) + name.substring(1);
1✔
43
    }
44

45
    return name;
1✔
46
  }
47

48
  public static boolean isProperty(String name) {
49
    return isGetter(name) || isSetter(name);
1✔
50
  }
51

52
  public static boolean isGetter(String name) {
53
    return (name.startsWith("get") && name.length() > 3) || (name.startsWith("is") && name.length() > 2);
1✔
54
  }
55

56
  public static boolean isSetter(String name) {
57
    return name.startsWith("set") && name.length() > 3;
1✔
58
  }
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