Skip to content

Support interface superclass#140

Merged
tim-aero merged 10 commits intoaerospike:mainfrom
tim-aero:support-interface-superclass
Jul 5, 2023
Merged

Support interface superclass#140
tim-aero merged 10 commits intoaerospike:mainfrom
tim-aero:support-interface-superclass

Conversation

@tim-aero
Copy link
Contributor

Currently the Java Object Mapper only respects Classes for hierarchy roots. If there is no functionality on the superclass it would often be expressed as a interface rather than an abstract class. This new version supports reading the @AerospikeRecord annotation off the interfaces too. Order of priority is:

  1. Configuration file
  2. Record level definitions
  3. First parent class with @AerospikeRecord
  4. Interface with @AerospikeRecord

tim-aero added 3 commits April 7, 2023 08:12
If classes implement an interface instead of extending an abstract
class, the Java Object Mapper should respect any AerospikeRecords
annotations on the interface.

The Object Mapper will look for definitions in the config file, then any
AerospikeRecords on the specific class, then the superclasses and
finally anything in the interface hierarchy. The first one which defines
a namespace will be the definition which is used.
@tim-aero tim-aero requested review from reugn and roimenashe April 10, 2023 15:38
Copy link
Contributor

@reugn reugn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tim-aero

  • Extend IReactiveAeroMapper with the new methods of IAeroMapper
  • Add a reactive test
  • Add a readme note about interface root support

Comment on lines 94 to 96
for (int i = 0; i < otherChildren.length; i++) {
this.children.add(otherChildren[i]);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addAll can be used

new SubClass1("Wilma")
);

mapper.save(container, container.children.get(0), container.children.get(1), container.children.get(2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should pass using mapper.save(container);

new SubClass1("Wilma")
);

mapper.save(container, container.children.get(0), container.children.get(1), container.children.get(2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passes using mapper.save(container);
What is the motivation behind passing inner objects to the save method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I copy-pasted the test with the only difference being the embedding of the children to make sure functionality was what was expected. But you're right, there's no need to explicitly save the children here as they're embedded.

tim-aero and others added 2 commits April 19, 2023 08:58
Co-authored-by: Eugene R. <reugpro@gmail.com>
Utilised "addAll" to add vararg children to parent, and removed redundant saving of nested children
<T> VirtualList<T> asBackedList(@NotNull Class<?> owningClazz, @NotNull Object key, @NotNull String binName, Class<T> elementClazz);

/**
* Get the IAerospikeClient which was used to create this mapper.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run formatter on this class to align javadocs comments.

public String toString() {
return "SubClass1: " + myName;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And new line between classes

@tim-aero tim-aero requested review from reugn and roimenashe June 7, 2023 04:18
@tim-aero tim-aero merged commit c584e2a into aerospike:main Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants