class RoleBindingOperationsImpl extends HasMetadataOperation<RoleBinding, RoleBindingList, Resource<RoleBinding>> {

  public static final String SERVICE_ACCOUNT = "ServiceAccount";
  public static final String USER = "User";
  public static final String GROUP = "Group";

  public RoleBindingOperationsImpl(Client client) {
    this(HasMetadataOperationsImpl.defaultContext(client));
  }

  public RoleBindingOperationsImpl(OperationContext context) {
    super(context.withApiGroupName(AUTHORIZATION)
        .withPlural("rolebindings"), RoleBinding.class, RoleBindingList.class);
  }

  @Override
  public RoleBindingOperationsImpl newInstance(OperationContext context) {
    return new RoleBindingOperationsImpl(context);
  }

  @Override
  protected RoleBinding handleCreate(RoleBinding resource) throws InterruptedException, IOException {
    return super.handleCreate(enrichRoleBinding(resource));
  }

  @Override
  protected RoleBinding modifyItemForReplaceOrPatch(Supplier<RoleBinding> current, RoleBinding binding) {
    return enrichRoleBinding(binding);
  }

  private RoleBinding enrichRoleBinding(RoleBinding binding) {
    RoleBindingBuilder builder = new RoleBindingBuilder(binding);

    if ((binding.getUserNames() != null && !binding.getUserNames().isEmpty()) ||
        (binding.getGroupNames() != null && !binding.getGroupNames().isEmpty())) {
      enrichFromUsersAndGroups(builder, binding.getUserNames(), binding.getGroupNames());
    } else {
      enrichFromSubjects(builder, binding.getSubjects());
      enrichSubjectsNamespace(builder);
    }

    return builder.build();
  }

  private void enrichSubjectsNamespace(RoleBindingBuilder builder) {
    builder.accept(new TypedVisitor<ObjectReferenceBuilder>() {
      @Override
      public void visit(ObjectReferenceBuilder o) {
        if (o.getKind() != null && o.getKind().equals(SERVICE_ACCOUNT)
            && (o.getNamespace() == null || o.getNamespace().isEmpty())) {
          o.withNamespace(getNamespace());
        }
      }
    });
  }

  private void enrichFromUsersAndGroups(RoleBindingBuilder builder, List<String> userNames, List<String> groupNames) {<FILL_FUNCTION_BODY>}

  private void enrichFromSubjects(RoleBindingBuilder builder, List<ObjectReference> subjects) {
    for (ObjectReference ref : subjects) {
      switch (ref.getKind()) {
        case USER:
          builder.addToUserNames(ref.getName());
          break;
        case SERVICE_ACCOUNT:
          String namespace = ref.getNamespace();
          if (namespace == null || namespace.isEmpty()) {
            namespace = getNamespace();
          }
          builder.addToUserNames("system:serviceaccount:" + namespace + ":" + ref.getName());
          break;
        case GROUP:
          builder.addToGroupNames(ref.getName());
          break;
      }
    }
  }
}

    builder.withSubjects();

    if (userNames != null) {
      for (String userName : userNames) {
        if (userName.startsWith("system:serviceaccount:")) {
          String[] splitUserName = userName.split(":");
          if (splitUserName.length == 4) {
            builder.addNewSubject().withKind(SERVICE_ACCOUNT).withNamespace(splitUserName[2]).withName(splitUserName[3])
                .endSubject();
            continue;
          }
        }

        builder.addNewSubject().withKind(USER).withName(userName).endSubject();
      }
    }

    if (groupNames != null) {
      for (String groupName : groupNames) {
        builder.addNewSubject().withKind(GROUP).withName(groupName).endSubject();
      }
    }
  
<methods>public void <init>(io.fabric8.kubernetes.client.dsl.internal.OperationContext, Class<RoleBinding>, Class<RoleBindingList>) ,public RoleBinding accept(Consumer<RoleBinding>) ,public RoleBinding edit(UnaryOperator<RoleBinding>) ,public transient RoleBinding edit(Visitor[]) ,public RoleBinding editStatus(UnaryOperator<RoleBinding>) ,public HasMetadataOperation<RoleBinding,RoleBindingList,Resource<RoleBinding>> newInstance(io.fabric8.kubernetes.client.dsl.internal.OperationContext) ,public RoleBinding patch() ,public RoleBinding patch(io.fabric8.kubernetes.client.dsl.base.PatchContext) ,public RoleBinding patch(io.fabric8.kubernetes.client.dsl.base.PatchContext, RoleBinding) ,public RoleBinding patch(io.fabric8.kubernetes.client.dsl.base.PatchContext, java.lang.String) ,public RoleBinding patchStatus() ,public RoleBinding patchStatus(RoleBinding) ,public RoleBinding replace() ,public RoleBinding replaceStatus() ,public RoleBinding scale(int) ,public RoleBinding scale(int, boolean) ,public Scale scale(Scale) ,public RoleBinding update() ,public RoleBinding updateStatus() <variables>public static final long DEFAULT_GRACE_PERIOD_IN_SECONDS,public static final io.fabric8.kubernetes.api.model.DeletionPropagation DEFAULT_PROPAGATION_POLICY,private static final Logger LOGGER,private static final java.lang.String PATCH_OPERATION,private static final java.lang.String REPLACE_OPERATION,private static final java.lang.String UPDATE_OPERATION