IndexedObjectContainer implements ObjectIndexProvider { @Nonnull protected Integer add( @Nonnull IdentifiableObject object ) { final Integer newIndex = objectsIndexMap.size(); final Integer existingIndex = objectsIndexMap.putIfAbsent( object, newIndex ); return ( existingIndex == null ) ? newIndex : existingIndex; }  @Nonnull @Override Integer mergeObjectIndex( @Nonnull IdentifiableObject object ); boolean containsObject( @Nonnull IdentifiableObject object );  }
@Test public void add() { final Attribute attribute1 = new Attribute(); final Attribute attribute2 = new Attribute(); final Attribute attribute3 = new Attribute(); Assert.assertEquals( (Integer) 0, container.add( attribute1 ) ); Assert.assertEquals( (Integer) 1, container.add( attribute2 ) ); Assert.assertEquals( (Integer) 0, container.add( attribute1 ) ); Assert.assertEquals( (Integer) 2, container.add( attribute3 ) ); }