class 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;
    }

}