class Groups {

    public synchronized Group getOrCreate( String name )
    {
        if ( isGlobalGroup( name ) )
        {
            return Group.GLOBAL;
        }

        Group group = byName.get( name );
        if ( group == null )
        {
            byName.put( name, group = new Group.Adapter( nextId++, name ) );
            byId.add( group );
        }
        return group;
    }

}