code: public static void setNewIdentifier(ModelElementType type, ModelElementInstance modelElementInstance,
                                     String newId, boolean withReferenceUpdate) {
      Attribute<?> id = type.getAttribute(ID_ATTRIBUTE_NAME);
      if (id != null && id instanceof StringAttribute && id.isIdAttribute()) {
        ((StringAttribute) id).setValue(modelElementInstance, newId, withReferenceUpdate);
      }
    }
docs: Set new identifier if the type has a String id attribute
  
  @param type the type of the model element
  @param modelElementInstance the model element instance to set the id
  @param newId new identifier
  @param withReferenceUpdate true to update id references in other elements, false otherwise