Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Strange-looking code in EMF
Strange-looking code in EMF [message #422938] Fri, 19 September 2008 11:30 Go to next message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi,

just by chance I came over this code:

if (eType.getInstanceClassName() == "java.util.Map$Entry")
[EStoreEObjectImpl:694]

I haven't worked with maps in EMF, but this looks strongly suspicious?

shouldn't == be .equals() ?!

Cheers,
Stefan
Re: Strange-looking code in EMF [message #422945 is a reply to message #422938] Fri, 19 September 2008 13:22 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi, Stefan,

This works because EClassifiers intern() their instance-class names, and
Java ensures that string constants are interned, so this is actually
more efficient than .equals() and it's correct.

Cheers,

Christian

-----8<-----

protected void basicSetInstanceClassName(String value)
{
if (instanceClassName == null && generatedInstanceClassName != null)
{
instanceClassName = generatedInstanceClassName;
generatedInstanceClassName = null;
}
setInstanceClassNameGen(value == null ? null : value.intern());
if (instanceClass != null)
{
setInstanceClassGen(null);
}
}

----->8-----

Stefan Winkler wrote:
> Hi,
>
> just by chance I came over this code:
>
> if (eType.getInstanceClassName() == "java.util.Map$Entry")
> [EStoreEObjectImpl:694]
>
> I haven't worked with maps in EMF, but this looks strongly suspicious?
>
> shouldn't == be .equals() ?!
>
> Cheers,
> Stefan
Previous Topic:Persisting _all_ values?
Next Topic:How to represent relationship in ecore?
Goto Forum:
  


Current Time: Mon Sep 28 22:02:53 GMT 2020

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

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

Back to the top