Java List Print prettyPrint(List userPermissions)

Here you can find the source of prettyPrint(List userPermissions)

Description

pretty Print

License

Open Source License

Declaration

public static String prettyPrint(List<String> userPermissions) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) [2012] - [2016] Codenvy, S.A.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from   w ww . ja v  a  2  s  . com
 *   Codenvy, S.A. - initial API and implementation
 *******************************************************************************/

import java.util.List;

public class Main {
    public static String prettyPrint(List<String> userPermissions) {
        if (userPermissions == null) {
            return "";
        }

        StringBuilder sb = new StringBuilder("");

        if (userPermissions.contains("read")) {
            sb.append("R");
        }
        if (userPermissions.contains("write")) {
            sb.append("W");
        }

        // build permission if before the run
        if (userPermissions.contains("build")) {
            sb.append("B");
        }

        if (userPermissions.contains("run")) {
            sb.append("X");
        }

        // Update ACL should be the last permission
        if (userPermissions.contains("update_acl")) {
            sb.append("U");
        }

        return sb.toString();
    }
}

Related

  1. getGenBlueprintName(String slavenodelist, List masterList)
  2. limitLengthOfPrintedList(Collection list)
  3. prettyList(final List list)
  4. prettyList(List list)
  5. prettyPrint(List rows)
  6. prettyPrintArgv(List argv)
  7. prettyPrintList(Collection objects, String separator)
  8. prettyPrintList(List list)