Skip to content
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

feat: Support getters/setters for annotations #968

Open
Christopher-Chianelli opened this issue Jun 20, 2024 · 0 comments
Open

feat: Support getters/setters for annotations #968

Christopher-Chianelli opened this issue Jun 20, 2024 · 0 comments
Labels
enhancement New feature or request process/needs triage Requires initial assessment of validity, priority etc. python Is related to Python code.

Comments

@Christopher-Chianelli
Copy link
Contributor

Christopher-Chianelli commented Jun 20, 2024

Is your feature request related to a problem? Please describe.
See TimefoldAI/timefold-solver-python#86

Describe the solution you'd like
The ability to annotate a getter/setter function pair for annotations that require setting fields, like PlanningVariable or PlanningEntityCollection:

class MyEntity:
    entities: list[Entity]
    
    def get_entities(self) -> Annotated[list[Entity], PlanningEntityCollection]:
        return self.entities
    
    def set_entities(self, entities):
        self.entities = entities

Describe alternatives you've considered
None

Additional context
Useful for whoever is migrating from optapy.

Note that Java will check for method names "get..." and "set...", so we will need to generate two additional methods. However, attributes also generate getter and setter methods, so it should has a prefix to distinguish it from the attribute getter/setter.

@Christopher-Chianelli Christopher-Chianelli added enhancement New feature or request process/needs triage Requires initial assessment of validity, priority etc. labels Jun 20, 2024
@triceo triceo transferred this issue from TimefoldAI/timefold-solver-python Jul 17, 2024
@triceo triceo added java Is related to Java code. python Is related to Python code. and removed java Is related to Java code. labels Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request process/needs triage Requires initial assessment of validity, priority etc. python Is related to Python code.
Projects
None yet
Development

No branches or pull requests

2 participants