New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AERIE-1858] Facilitate recommended pattern for computed attributes #188
[AERIE-1858] Facilitate recommended pattern for computed attributes #188
Conversation
6a5a5b4
to
627c95e
Compare
@mattdailis, I haven't had a chance to look too deeply at this yet, but I have a quick question. If a user opts not to use |
...ework-processor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/MissionModelProcessor.java
Outdated
Show resolved
Hide resolved
...ework-processor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/MissionModelProcessor.java
Outdated
Show resolved
Hide resolved
...ework-processor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/MissionModelProcessor.java
Outdated
Show resolved
Hide resolved
...ework-processor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/MissionModelProcessor.java
Outdated
Show resolved
Hide resolved
...ework-processor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/MissionModelProcessor.java
Outdated
Show resolved
Hide resolved
...ework-processor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/MissionModelProcessor.java
Outdated
Show resolved
Hide resolved
...essor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/generator/MissionModelGenerator.java
Outdated
Show resolved
Hide resolved
...essor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/generator/MissionModelGenerator.java
Outdated
Show resolved
Hide resolved
396ff16
to
b424c9b
Compare
9faed61
to
353fce5
Compare
353fce5
to
8814983
Compare
@mattdailis Sorry if I'm just out of the loop but what's the state of this PR? Is it in kind of a do-not-merge place right now? |
It's available for review! I probably need to rebase/resolve merge conflicts, I can do that tomorrow morning 👍 |
...essor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/generator/MissionModelGenerator.java
Outdated
Show resolved
Hide resolved
...essor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/generator/MissionModelGenerator.java
Outdated
Show resolved
Hide resolved
...rocessor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/metamodel/MissionModelRecord.java
Outdated
Show resolved
Hide resolved
...essor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/generator/MissionModelGenerator.java
Outdated
Show resolved
Hide resolved
...essor/src/main/java/gov/nasa/jpl/aerie/merlin/processor/generator/MissionModelGenerator.java
Outdated
Show resolved
Hide resolved
@mattdailis let me know if you want/need to pair at all to get this PR through 👌 The conflicts with |
36e43ab
to
c420b0a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work Matt!
Last question/comment I have is about the @AutoValueMapper
. I'm wondering if this should be called RecordValueMapper
or something that indicates it's only supported for computed attribute return types.
Maybe the thinking is that this annotation will eventually support auto value mappers for other parts of mission model? If not then I could see it causing some confusion if developers think it's truly an auto value mapper (without context).
I can definitely see this being extended to activity types in the future -- I'm imagining this coming in when we extract resource registration out of model initialization. At that point we should probably move activity type registration into the same place that resource registration ends up, which would mean |
c420b0a
to
6d06027
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's all great. Thank you for the tour, it definitely helped. I only have two minor non-blocking comments.
...ib/src/test/java/gov/nasa/jpl/aerie/contrib/serialization/mappers/RecordValueMapperTest.java
Outdated
Show resolved
Hide resolved
...framework/src/main/java/gov/nasa/jpl/aerie/merlin/framework/annotations/AutoValueMapper.java
Outdated
Show resolved
Hide resolved
6d06027
to
2768d3f
Compare
e971a57
to
a0ec898
Compare
a0ec898
to
a86e100
Compare
a86e100
to
0bedf45
Compare
Description
The goal of this PR is to demonstrate a recommended pattern for declaring computed attributes. We think that the most idiomatic way to declare computed attributes is with a
record
, like so:aerie/examples/banananation/src/main/java/gov/nasa/jpl/aerie/banananation/activities/BiteBananaActivity.java
Lines 29 to 39 in 6a5a5b4
Records are a low-boilerplate mechanism for expressing sets of key-value pairs, where the keys are fixed (as opposed to
Maps
, which describe sets key-value pairs where the keys are dynamic).Prior to this PR, it is still definitely possible to use
records
for computed attributes. However, every new record type would need a correspondingValueMapper
to be added to the value mapper factory.In the interest of making our "recommended practice" as easy as possible for users, this PR adds an
@AutoValueMapper
annotation. This annotation can only be applied to records, and it will generate anAutoValueMappers.java
file that contains a method that looks like this:It will simultaneously create a
TypeRule
that would have been the result of parsing that factory method, had that method been defined prior to annotation processing.Verification
I have added unit tests for
RecordValueMapper
. I've also done some visual spot checking. What I would still like to do prior to merging this PR is some end-to-end tests, just as a sanity check that the serialization/deserialization doesn't hit any snagsValue Schema
- [ ] manual e2e test where AutoValueMapper is used as a parameterDocumentation
The existing documentation already recommends using a
Map
. We should just update it to recommend arecord
instead.Perhaps an extra section on
@AutoValueMapper
should be added to our ValueMapper docs.Future work