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

HotelsDotCom / waggle-dance / #318

pending completion
#318

push

web-flow
Feature/upgrade springboot (#268)

* update springboot to 2.1.18

* update springboot to 2.2.13

* Upgrade to srping boot 2.7.11

* Update changelog

* Update changelog

* fix version

3 of 3 new or added lines in 2 files covered. (100.0%)

132 of 3058 relevant lines covered (4.32%)

0.04 hits per line

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

0.0
/waggle-dance-core/src/main/java/com/hotels/bdp/waggledance/yaml/AdvancedPropertyUtils.java
1
/**
2
 * Copyright (C) 2016-2019 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.hotels.bdp.waggledance.yaml;
17

18
import java.beans.PropertyDescriptor;
19
import java.beans.Transient;
20
import java.lang.reflect.Field;
21
import java.lang.reflect.Method;
22
import java.util.Collection;
23
import java.util.Set;
24
import java.util.TreeSet;
25

26
import org.yaml.snakeyaml.introspector.BeanAccess;
27
import org.yaml.snakeyaml.introspector.MethodProperty;
28
import org.yaml.snakeyaml.introspector.Property;
29
import org.yaml.snakeyaml.introspector.PropertyUtils;
30

31
import com.google.common.base.CaseFormat;
32

33
public class AdvancedPropertyUtils extends PropertyUtils {
×
34

35
  private boolean allowReadOnlyProperties = false;
×
36

37
  @Override
38
  public Property getProperty(Class<?> type, String name) {
39
    if (name.indexOf('-') > -1) {
×
40
      name = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, name);
×
41
    }
42
    return super.getProperty(type, name);
×
43
  }
44

45
  @Override
46
  protected Set<Property> createPropertySet(Class<?> type, BeanAccess beanAccess) {
47
    Set<Property> properties = new TreeSet<>();
×
48
    Collection<Property> props = getPropertiesMap(type, beanAccess).values();
×
49
    for (Property property : props) {
×
50
      if (include(property)) {
×
51
        properties.add(property);
×
52
      }
53
    }
54
    return properties;
×
55
  }
56

57
  private synchronized boolean include(Property property) {
58
    boolean eligible = property.isReadable() && (allowReadOnlyProperties || property.isWritable());
×
59
    if (!eligible) {
×
60
      return false;
×
61
    }
62
    if (MethodProperty.class.isAssignableFrom(property.getClass())) {
×
63
      PropertyDescriptor propertyDescriptor = getPropertyDescriptor((MethodProperty) property);
×
64
      return propertyDescriptor == null || !isTransient(propertyDescriptor);
×
65
    }
66
    return true;
×
67
  }
68

69
  private synchronized PropertyDescriptor getPropertyDescriptor(MethodProperty methodProperty) {
70
    Field propertyField = null;
×
71
    try {
72
      propertyField = MethodProperty.class.getDeclaredField("property");
×
73
      propertyField.setAccessible(true);
×
74
      return (PropertyDescriptor) propertyField.get(methodProperty);
×
75
    } catch (Exception e) {
×
76
      return null;
×
77
    } finally {
78
      if (propertyField != null) {
×
79
        propertyField.setAccessible(false);
×
80
      }
81
    }
82
  }
83

84
  private boolean isTransient(PropertyDescriptor propertyDescriptor) {
85
    // first check for a write method to avoid NullPointerException
86
    Method writeMethod = propertyDescriptor.getWriteMethod();
×
87

88
    return propertyDescriptor.getReadMethod().getAnnotation(Transient.class) != null
×
89
        || (writeMethod != null && writeMethod.getAnnotation(Transient.class) != null);
×
90
  }
91

92
  @Override
93
  public void setAllowReadOnlyProperties(boolean allowReadOnlyProperties) {
94
    this.allowReadOnlyProperties = allowReadOnlyProperties;
×
95
    super.setAllowReadOnlyProperties(allowReadOnlyProperties);
×
96
  }
×
97

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

© 2026 Coveralls, Inc