Example usage for java.util Collections unmodifiableSortedSet

List of usage examples for java.util Collections unmodifiableSortedSet

Introduction

In this page you can find the example usage for java.util Collections unmodifiableSortedSet.

Prototype

public static <T> SortedSet<T> unmodifiableSortedSet(SortedSet<T> s) 

Source Link

Document

Returns an unmodifiable view of the specified sorted set.

Usage

From source file:org.apache.tephra.hbase.txprune.DataJanitorState.java

/**
 * Return regions that were recorded as empty after the given time.
 *
 * @param time time in milliseconds//from  w w  w  . ja v  a 2 s  .co  m
 * @param includeRegions If not null, the returned set will be an intersection of the includeRegions set
 *                       and the empty regions after the given time
 */
public SortedSet<byte[]> getEmptyRegionsAfterTime(long time, @Nullable SortedSet<byte[]> includeRegions)
        throws IOException {
    SortedSet<byte[]> emptyRegions = new TreeSet<>(Bytes.BYTES_COMPARATOR);
    try (Table stateTable = stateTableSupplier.get()) {
        Scan scan = new Scan(makeEmptyRegionTimeKey(Bytes.toBytes(time + 1), EMPTY_BYTE_ARRAY),
                EMPTY_REGION_TIME_KEY_PREFIX_STOP);
        scan.addColumn(FAMILY, EMPTY_REGION_TIME_COL);

        try (ResultScanner scanner = stateTable.getScanner(scan)) {
            Result next;
            while ((next = scanner.next()) != null) {
                byte[] emptyRegion = getEmptyRegionFromKey(next.getRow());
                if (includeRegions == null || includeRegions.contains(emptyRegion)) {
                    emptyRegions.add(emptyRegion);
                }
            }
        }
    }
    return Collections.unmodifiableSortedSet(emptyRegions);
}

From source file:org.web4thejob.web.panel.base.AbstractBorderLayoutPanel.java

@Override
public SortedSet<Command> getMergedCommands() {
    SortedSet<Command> mergedCommands = new TreeSet<Command>(super.getCommands());

    if (getCommandRenderer() == null) {
        mergeCommands();//  w  w w  . j av a  2s . c om
    }

    for (CommandAware commandAware : getCommandRenderer().getCommandOwners()) {
        if (!getCommandRenderer().getPrimaryOwner().equals(commandAware)) {
            SortedSet<Command> commands;
            if (commandAware instanceof CommandMerger) {
                commands = ((CommandMerger) commandAware).getMergedCommands();
            } else {
                commands = commandAware.getCommands();
            }
            for (Command command : commands) {
                if (commandAware instanceof CommandMerger) {
                    //hinto for ToolbarRenderer so that in multiple command mergers scenario
                    //the last merger (panel) can be identified so that it can be correctly mapped
                    //to the correct region and this region settings can be applied (eg NORTH_EXCLUDE_CRUD_COMMANDS)
                    command.setArg(CommandMerger.ATTRIB_COMMAND_MERGER, commandAware);
                }
                mergedCommands.add(command);
            }
        }
    }

    return Collections.unmodifiableSortedSet(mergedCommands);
}

From source file:com.atlassian.jira.user.util.UserUtilImpl.java

public SortedSet<Group> getGroupsForUser(final String userName) {
    notNull("userName", userName);
    final SortedSet<Group> setOfGroups = new TreeSet<Group>();

    Iterable<Group> groups = getGroupsForUserFromCrowd(userName);
    for (Group group : groups) {
        setOfGroups.add(group);//w  ww. j  a va 2 s.c om
    }
    return Collections.unmodifiableSortedSet(setOfGroups);
}

From source file:com.atlassian.jira.user.util.UserUtilImpl.java

public SortedSet<String> getGroupNamesForUser(final String userName) {
    notNull("userName", userName);
    final SortedSet<String> setOfGroups = new TreeSet<String>();

    Iterable<String> groups = getGroupNamesForUserFromCrowd(userName);
    for (String groupName : groups) {
        setOfGroups.add(groupName);//  w ww.j a va2s  .c  om
    }
    return Collections.unmodifiableSortedSet(setOfGroups);
}

From source file:com.atlassian.jira.bc.group.DefaultGroupService.java

@Override
public Collection<String> getChildGroupNames(com.atlassian.crowd.embedded.api.Group group) {
    final com.atlassian.crowd.search.query.membership.MembershipQuery<com.atlassian.crowd.embedded.api.Group> membershipQuery = QueryBuilder
            .queryFor(com.atlassian.crowd.embedded.api.Group.class, EntityDescriptor.group())
            .childrenOf(EntityDescriptor.group()).withName(group.getName())
            .returningAtMost(EntityQuery.ALL_RESULTS);

    final SortedSet<String> setOfGroups = new TreeSet<String>();

    Iterable<com.atlassian.crowd.embedded.api.Group> children = crowdService.search(membershipQuery);
    for (com.atlassian.crowd.embedded.api.Group child : children) {
        if (crowdService.isGroupDirectGroupMember(child, group)) {
            setOfGroups.add(child.getName());
        }// w  w  w  .j a va  2  s.c  o m
    }
    return Collections.unmodifiableSortedSet(setOfGroups);
}

From source file:com.atlassian.jira.bc.group.DefaultGroupService.java

@Override
public Collection<String> getParentGroupNames(com.atlassian.crowd.embedded.api.Group group) {
    final com.atlassian.crowd.search.query.membership.MembershipQuery<com.atlassian.crowd.embedded.api.Group> membershipQuery = QueryBuilder
            .queryFor(com.atlassian.crowd.embedded.api.Group.class, EntityDescriptor.group())
            .parentsOf(EntityDescriptor.group()).withName(group.getName())
            .returningAtMost(EntityQuery.ALL_RESULTS);

    final SortedSet<String> setOfGroups = new TreeSet<String>();

    Iterable<com.atlassian.crowd.embedded.api.Group> parents = crowdService.search(membershipQuery);
    for (com.atlassian.crowd.embedded.api.Group parent : parents) {
        if (crowdService.isGroupDirectGroupMember(group, parent)) {
            setOfGroups.add(parent.getName());
        }/*from ww  w .  j a  va 2s  .  c o m*/
    }
    return Collections.unmodifiableSortedSet(setOfGroups);
}

From source file:org.rapla.storage.impl.server.LocalAbstractCachableOperator.java

protected SortedSet<Appointment> getAppointments(Allocatable allocatable) {
    String allocatableId = allocatable != null ? allocatable.getId() : null;
    SortedSet<Appointment> s = appointmentMap.get(allocatableId);
    if (s == null) {
        return EMPTY_SORTED_SET;
    }//  ww  w . j a v a  2  s  .co  m
    return Collections.unmodifiableSortedSet(s);
}

From source file:com.gtwm.pb.model.manageSchema.DatabaseDefn.java

public Map<TableInfo, Set<BaseReportInfo>> getViewableDataStores(HttpServletRequest request)
        throws CodingErrorException, ObjectNotFoundException {
    // Get the list of viewable tables and reports, for possible use in
    // replacing user input fields etc. with internal names
    // TODO: Shares common code with ViewMethods.getViewableReports/Tables,
    // refactor//from   w  w  w.  j a v a 2 s .  com
    // Actually, if/when we add report privileges this will be obsolete
    // anyway
    Map<TableInfo, Set<BaseReportInfo>> availableDataStores = new HashMap<TableInfo, Set<BaseReportInfo>>();
    Set<TableInfo> companyTables = this.getAuthManager().getCompanyForLoggedInUser(request).getTables();
    AuthenticatorInfo authenticator = this.getAuthManager().getAuthenticator();
    for (TableInfo testTable : companyTables) {
        if (authenticator.loggedInUserAllowedTo(request, PrivilegeType.VIEW_TABLE_DATA, testTable)) {
            SortedSet<BaseReportInfo> allTableReports = testTable.getReports();
            // Strip down to the set of reports the user has privileges to
            // view
            SortedSet<BaseReportInfo> viewableReports = new TreeSet<BaseReportInfo>();
            for (BaseReportInfo report : allTableReports) {
                if (authenticator.loggedInUserAllowedToViewReport(request, report)) {
                    viewableReports.add(report);
                }
            }
            availableDataStores.put(testTable, Collections.unmodifiableSortedSet(viewableReports));
        }
    }
    return Collections.unmodifiableMap(availableDataStores);
}