Coder Social home page Coder Social logo

Allow mixed-type equals about aas4j HOT 3 OPEN

mhrimaz avatar mhrimaz commented on July 18, 2024
Allow mixed-type equals

from aas4j.

Comments (3)

mjacoby avatar mjacoby commented on July 18, 2024

If we go for mixed-type equality, can we assure that all (future) implementation of an interface like Property will behave in the same expected way or is this up to the developer of each of those classes? If we can't ensure this, might this be a problem?
Does this even require major effort on our site to implement/support this as we only provide a single implementation of each interface?
In general I like the idea of allowing mixed-types equality but only if it makes sense and we don't find major downsides (besides complexity).
One potential downside I can think of is that currently the model code, i.e. also the equals methods, are auto-generated by our generator tool and I am not sure if such a complex pattern could also be auto-generated.

RelationshipElement and AnnotatedRelationshipElement are a special case and I guess an instance of AnnotatedRelationshipElement should never be considered equal to an instance of RelationshipElement. Reasoning is, that if you follow through with this logic you should also consider an empty Property equal to an empty Range element because both are instances of SubmodelElement and in this case they would ne differ in attributes.

from aas4j.

mhrimaz avatar mhrimaz commented on July 18, 2024

If we go for mixed-type equality, can we assure that all (future) implementation of an interface like Property will behave in the same expected way or is this up to the developer of each of those classes? If we can't ensure this, might this be a problem? Does this even require major effort on our site to implement/support this as we only provide a single implementation of each interface? In general I like the idea of allowing mixed-types equality but only if it makes sense and we don't find major downsides (besides complexity). One potential downside I can think of is that currently the model code, i.e. also the equals methods, are auto-generated by our generator tool and I am not sure if such a complex pattern could also be auto-generated.

We can't control how people implement their equals, but all we can is to provide examples and sample test cases to guide them through a correct implementation.
I also don't say definitely that we should have such attribute for equals. The motivation was to test if a CustomProperty can be serialized with RDF serializer, but the reconstructed object for now is always DefaultProperty. So I can't compare them using equals method right now.

RelationshipElement and AnnotatedRelationshipElement are a special case and I guess an instance of AnnotatedRelationshipElement should never be considered equal to an instance of RelationshipElement. Reasoning is, that if you follow through with this logic you should also consider an empty Property equal to an empty Range element because both are instances of SubmodelElement and in this case they would ne differ in attributes.

I also think so. In this case, I need to modify also the current PR if we want to have such behaviour.

from aas4j.

mjacoby avatar mjacoby commented on July 18, 2024

The motivation was to test if a CustomProperty can be serialized with RDF serializer, but the reconstructed object for now is always DefaultProperty. So I can't compare them using equals method right now.

Another possible solution for this problem would be to add a method similar to useImplementation(Class<T> aasInterface, Class>? extends T> implementation) in JsonDeserializer.java#L59 also for RDF.
I think this would be very beneficial. And if you have something like this it would solve your problem related to testing.

However, this would not answer the question if we should change how equals work in AAS4J (or in certain classes at least).

from aas4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.