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

Extend java static meta model accessors #516

Merged

Conversation

andreas-schilling
Copy link
Contributor

Fixes #515

@andreas-schilling
Copy link
Contributor Author

While I consider the PR to be fine as it is, there is also an alternative way to implement this.
The accessor method could be extracted to its own interface

public interface PropertyAccessor<C, T> {
   T getValue( C object );
}

so that the static property changes to

public abstract class StaticProperty<C, T> extends DefaultProperty implements PropertyAccessor<C, T>

This doesn't change much in a first stage, however if we think a bit further into the direction of chained properties, computed properties or other ad-hoc defined metamodel elements (either at compile- or at runtime), this would allow writing static-like code also on non-static metamodel elements, that might have been dynamically loaded during runtime.

This could be handy when operating on certain properties in a truly generic application scenario where the meta information of some part is known to the developer (like "I want to operate on a property that represents a temperature measurement, independent from the Aspect/Entity surrounding it and I also don't even know what meta model elements I get hold of while the application runs").
I know that this is a tad abstract and also only gains the same amount of type safety when it is implemented using runtime checks that guarantee, that the implemented bits can only be applied to data that actually matches the ad-hoc meta information.
Still, the change as of now would be rather small and I could adjust the PR accordingly.

WDYT?

@atextor
Copy link
Contributor

atextor commented Jan 29, 2024

While I consider the PR to be fine as it is, there is also an alternative way to implement this. The accessor method could be extracted to its own interface

public interface PropertyAccessor<C, T> {
   T getValue( C object );
}

so that the static property changes to

public abstract class StaticProperty<C, T> extends DefaultProperty implements PropertyAccessor<C, T>

This doesn't change much in a first stage, however if we think a bit further into the direction of chained properties, computed properties or other ad-hoc defined metamodel elements (either at compile- or at runtime), this would allow writing static-like code also on non-static metamodel elements, that might have been dynamically loaded during runtime.

This could be handy when operating on certain properties in a truly generic application scenario where the meta information of some part is known to the developer (like "I want to operate on a property that represents a temperature measurement, independent from the Aspect/Entity surrounding it and I also don't even know what meta model elements I get hold of while the application runs"). I know that this is a tad abstract and also only gains the same amount of type safety when it is implemented using runtime checks that guarantee, that the implemented bits can only be applied to data that actually matches the ad-hoc meta information. Still, the change as of now would be rather small and I could adjust the PR accordingly.

WDYT?

I like the idea of having this and I'd be fine with both approaches, adjusting this PR or create a new one with this change. I approved this PR as-is and I leave it up to you if you'd like to change it again or rather create a separate one. The only thing I'd ask for in addition would be some user documentation (in java-aspect-tooling.adoc) that explains how to use this feature.

@atextor atextor merged commit 3ad1a49 into eclipse-esmf:main Jan 29, 2024
3 checks passed
@atextor atextor deleted the 515-extend-java-static-meta-model-accessors branch January 29, 2024 09:59
Copy link

Release v2.5.1 addresses this.

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.

[Task] Extend Java static meta model with accessor functionality
2 participants