DATACMNS-1206 - Add API to read methods in declaration order.
We now provide MethodsMetadataReader to read method metadata from a class file. MethodMetadata is read for all user-declared methods except for constructors (which are technically methods, too).
MethodsMetadataReaderFactory factory = new MethodsMetadataReaderFactory();
MethodsMetadataReader metadataReader = factory.getMetadataReader("com.acme.Foo");
MethodsMetadata metadata = metadataReader.getMethodsMetadata();
This new API is now used by DefaultProjectionInformation to make sure the order of input properties is based on the declaration order in the projection interfaces. Previously that order could not be guaranteed to be stable.
Original pull request: #263.
This commit is contained in:
@@ -28,6 +28,7 @@ import org.junit.Test;
|
||||
* Unit tests for {@link DefaultProjectionInformation}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class DefaultProjectionInformationUnitTests {
|
||||
|
||||
@@ -47,6 +48,23 @@ public class DefaultProjectionInformationUnitTests {
|
||||
assertThat(toNames(information.getInputProperties())).containsExactly("age", "firstname", "lastname");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1206
|
||||
public void discoversInputPropertiesInOrder() {
|
||||
|
||||
ProjectionInformation information = new DefaultProjectionInformation(SameMethodNamesInAlternateOrder.class);
|
||||
|
||||
assertThat(toNames(information.getInputProperties())).containsExactly("firstname", "lastname");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1206
|
||||
public void discoversAllInputPropertiesInOrder() {
|
||||
|
||||
assertThat(toNames(new DefaultProjectionInformation(CompositeProjection.class).getInputProperties()))
|
||||
.containsExactly("firstname", "lastname", "age");
|
||||
assertThat(toNames(new DefaultProjectionInformation(ReorderedCompositeProjection.class).getInputProperties()))
|
||||
.containsExactly("age", "firstname", "lastname");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-967
|
||||
public void doesNotConsiderDefaultMethodInputProperties() throws Exception {
|
||||
|
||||
@@ -76,6 +94,24 @@ public class DefaultProjectionInformationUnitTests {
|
||||
int getAge();
|
||||
}
|
||||
|
||||
interface SameMethodNamesInAlternateOrder {
|
||||
|
||||
String getFirstname();
|
||||
|
||||
String getLastname();
|
||||
|
||||
String getFirstname(String foo);
|
||||
}
|
||||
|
||||
interface CompositeProjection extends CustomerProjection, AgeProjection {}
|
||||
|
||||
interface ReorderedCompositeProjection extends AgeProjection, CustomerProjection {}
|
||||
|
||||
interface AgeProjection {
|
||||
|
||||
int getAge();
|
||||
}
|
||||
|
||||
interface WithDefaultMethod {
|
||||
|
||||
String getFirstname();
|
||||
|
||||
Reference in New Issue
Block a user