Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » No .getEEnumLiteral() method in Enumerator interface
No .getEEnumLiteral() method in Enumerator interface [message #424631] Fri, 31 October 2008 15:59 Go to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello!

Why don't we have Enumerator.getEEnumLiteral() method? Is there any other
way to get appropriate EEnumLiteral/EEnum instance having only Enumerator
instance?

-----------------
Alex Shatalin
Re: No .getEEnumLiteral() method in Enumerator interface [message #424657 is a reply to message #424631] Fri, 31 October 2008 16:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Alex,

There's EEnum.getEEnumLiteralByLiteral(String) but I guess that's not
what you mean. Enumerator is in org.eclipse.emf.common and knows nothing
about Ecore. There's not much you can do with just an Enumerator instance...


Alex Shatalin wrote:
> Hello!
>
> Why don't we have Enumerator.getEEnumLiteral() method? Is there any
> other way to get appropriate EEnumLiteral/EEnum instance having only
> Enumerator instance?
>
> -----------------
> Alex Shatalin
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: No .getEEnumLiteral() method in Enumerator interface [message #424660 is a reply to message #424657] Fri, 31 October 2008 17:15 Go to previous messageGo to next message
Cameron Bateman is currently offline Cameron BatemanFriend
Messages: 481
Registered: July 2009
Senior Member
> There's EEnum.getEEnumLiteralByLiteral(String) but I guess that's not
> what you mean. Enumerator is in org.eclipse.emf.common and knows nothing
> about Ecore. There's not much you can do with just an Enumerator instance...

So if you have an Enumerator instance, e, and you know what sub-class of
EEnum you think you want a literal for, say enum, could you call:

enum.getEEnumLiteralByLiteral(e.getLiteral())?
or
enum.getEEnumLiteral(e.getValue())

I guess this would only be as type-safe as your assumption about enum.


--Cam
Re: No .getEEnumLiteral() method in Enumerator interface [message #424663 is a reply to message #424660] Fri, 31 October 2008 17:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Cameron,

Yes, in general values of data types don't know their data type the way
EObject.eClass() does. But EClassifier.isInstance lets you test to
ensure that the value conforms to the data type's Java class...


Cameron Bateman wrote:
>> There's EEnum.getEEnumLiteralByLiteral(String) but I guess that's not
>> what you mean. Enumerator is in org.eclipse.emf.common and knows
>> nothing about Ecore. There's not much you can do with just an
>> Enumerator instance...
>
> So if you have an Enumerator instance, e, and you know what sub-class
> of EEnum you think you want a literal for, say enum, could you call:
>
> enum.getEEnumLiteralByLiteral(e.getLiteral())?
> or
> enum.getEEnumLiteral(e.getValue())
>
> I guess this would only be as type-safe as your assumption about enum.
>
>
> --Cam
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: No .getEEnumLiteral() method in Enumerator interface [message #424713 is a reply to message #424657] Mon, 03 November 2008 12:37 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Ed,

> There's EEnum.getEEnumLiteralByLiteral(String) but I guess that's not
> what you mean. Enumerator is in org.eclipse.emf.common and knows
Yes, in the current code I have a place where I can get Enumerator instance
and have to return meta-object for it (EEnum instance). I know that I can
work around this place by modifying my code especially taking into account
your comment concerning other EDataType instances.

I was just thinking about the reason why Enumerator has no .eEnum() method
(just like EObject.eClass()) and it looks like it was done to keep Enumerator
interface out of dependency on ecore plugin.

Was this interface intentionally places out of Ecore?

-----------------
Alex Shatalin
Re: No .getEEnumLiteral() method in Enumerator interface [message #424717 is a reply to message #424713] Mon, 03 November 2008 12:59 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Alex,

Yes, it was intentional to make the interface for enumerators not
depend on Ecore. Consider for example that for an XML Schema based
model we always generated a second EDataType that wraps the generated
enum class so that the resulting EDataType supports null as a value. In
that case, there is always an EEnum and an EDataType, either of which
could be the EClassifier for the enumerator instance. You're right
though that we could have designed it differently...


Alex Shatalin wrote:
> Hello Ed,
>
>> There's EEnum.getEEnumLiteralByLiteral(String) but I guess that's not
>> what you mean. Enumerator is in org.eclipse.emf.common and knows
> Yes, in the current code I have a place where I can get Enumerator
> instance and have to return meta-object for it (EEnum instance). I
> know that I can work around this place by modifying my code especially
> taking into account your comment concerning other EDataType instances.
>
> I was just thinking about the reason why Enumerator has no .eEnum()
> method (just like EObject.eClass()) and it looks like it was done to
> keep Enumerator interface out of dependency on ecore plugin.
> Was this interface intentionally places out of Ecore?
> -----------------
> Alex Shatalin
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Set Property Type Dinamically
Next Topic:[CDO] CDOView is expected to be used by one thread ?
Goto Forum:
  


Current Time: Fri Apr 26 06:21:54 GMT 2024

Powered by FUDForum. Page generated in 0.03701 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top