Commit e7eb7739 authored by Andy Wilkinson's avatar Andy Wilkinson

Use overriding rather than overridden getter methods in config prop AP

Fixes gh-23966
parent 79a83353
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -74,7 +74,7 @@ class TypeElementMembers { ...@@ -74,7 +74,7 @@ class TypeElementMembers {
private void processMethod(ExecutableElement method) { private void processMethod(ExecutableElement method) {
if (isPublic(method)) { if (isPublic(method)) {
String name = method.getSimpleName().toString(); String name = method.getSimpleName().toString();
if (isGetter(method) && !this.publicGetters.containsKey(name)) { if (isGetter(method) && !this.publicGetters.containsKey(getAccessorName(name))) {
this.publicGetters.put(getAccessorName(name), method); this.publicGetters.put(getAccessorName(name), method);
} }
else if (isSetter(method)) { else if (isSetter(method)) {
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -75,6 +75,10 @@ class PropertyDescriptorResolverTests { ...@@ -75,6 +75,10 @@ class PropertyDescriptorResolverTests {
PropertyDescriptorResolver resolver = new PropertyDescriptorResolver(metadataEnv); PropertyDescriptorResolver resolver = new PropertyDescriptorResolver(metadataEnv);
assertThat(resolver.resolve(type, null).map(PropertyDescriptor::getName)).containsExactly("third", assertThat(resolver.resolve(type, null).map(PropertyDescriptor::getName)).containsExactly("third",
"second", "first"); "second", "first");
assertThat(resolver.resolve(type, null).map(
(descriptor) -> descriptor.getGetter().getEnclosingElement().getSimpleName().toString()))
.containsExactly("HierarchicalProperties", "HierarchicalPropertiesParent",
"HierarchicalPropertiesParent");
assertThat(resolver.resolve(type, null) assertThat(resolver.resolve(type, null)
.map((descriptor) -> descriptor.resolveItemMetadata("test", metadataEnv)) .map((descriptor) -> descriptor.resolveItemMetadata("test", metadataEnv))
.map(ItemMetadata::getDefaultValue)).containsExactly("three", "two", "one"); .map(ItemMetadata::getDefaultValue)).containsExactly("three", "two", "one");
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -33,7 +33,8 @@ public abstract class HierarchicalPropertiesParent extends HierarchicalPropertie ...@@ -33,7 +33,8 @@ public abstract class HierarchicalPropertiesParent extends HierarchicalPropertie
this.second = second; this.second = second;
} }
// Useless override // Overridden properties should belong to this class, not
// HierarchicalPropertiesGrandparent
@Override @Override
public String getFirst() { public String getFirst() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment