Example usage for java.util Collections unmodifiableSet

List of usage examples for java.util Collections unmodifiableSet

Introduction

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

Prototype

public static <T> Set<T> unmodifiableSet(Set<? extends T> s) 

Source Link

Document

Returns an unmodifiable view of the specified set.

Usage

From source file:com.jeremydyer.nifi.FaceDetectionProcessor.java

@Override
protected void init(final ProcessorInitializationContext context) {
    final List<PropertyDescriptor> descriptors = new ArrayList<PropertyDescriptor>();
    descriptors.add(FACE_CLASSIFIER);/*from  www  .  j a  v  a 2s. c  o  m*/
    descriptors.add(LEFT_EYE_CLASSIFIER);
    descriptors.add(RIGHT_EYE_CLASSIFIER);
    this.descriptors = Collections.unmodifiableList(descriptors);

    final Set<Relationship> relationships = new HashSet<Relationship>();
    relationships.add(REL_ORIGINAL);
    relationships.add(REL_OBJECT_DETECTED);
    relationships.add(REL_NO_OBJECT_DETECTED);
    relationships.add(REL_FAILURE);
    this.relationships = Collections.unmodifiableSet(relationships);

    //Load the OpenCV Native Library
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}

From source file:com.thinkbiganalytics.nifi.v2.ingest.AbstractMergeTable.java

public AbstractMergeTable() {
    final Set<Relationship> r = new HashSet<>();
    r.add(REL_SUCCESS);/* w w w .  jav a2 s .  c o  m*/
    r.add(REL_FAILURE);
    relationships = Collections.unmodifiableSet(r);

    List<PropertyDescriptor> pds = new ArrayList<>();
    pds.add(THRIFT_SERVICE);
    pds.add(MERGE_STRATEGY);
    pds.add(SOURCE_SCHEMA);
    pds.add(SOURCE_TABLE);
    pds.add(TARGET_SCHEMA);
    pds.add(TARGET_TABLE);
    pds.add(FEED_PARTITION);
    pds.add(PARTITION_SPECIFICATION);
    pds.add(FIELD_SPECIFICATION);
    pds.add(HIVE_CONFIGURATIONS);
    pds.add(RESET_HIVE);
    addPropertyDescriptors(pds);
    propDescriptors = Collections.unmodifiableList(pds);
}

From source file:at.beris.virtualfile.FileContext.java

public Set<Protocol> enabledProtocols() {
    Map<Protocol, Pair<String, String>> protocolClassMap = new HashMap<>();
    protocolClassMap.put(Protocol.SFTP, Pair.of("JSch", "com.jcraft.jsch.JSch"));
    protocolClassMap.put(Protocol.FTP, Pair.of("Apache Commons Net", "org.apache.commons.net.ftp.FTP"));

    Set<Protocol> enabledProtocols = new HashSet<>();
    enabledProtocols.add(Protocol.FILE);

    for (Map.Entry<Protocol, Pair<String, String>> entry : protocolClassMap.entrySet()) {
        Protocol protocol = entry.getKey();
        Pair<String, String> protocolLibrary = entry.getValue();
        try {//w ww.j  a  va  2s. c o m
            if (Class.forName(protocolLibrary.getRight()) != null)
                enabledProtocols.add(protocol);
        } catch (ClassNotFoundException e) {
        }
        if (!enabledProtocols.contains(protocol))
            LOGGER.info(protocolLibrary.getLeft() + " not installed. No support for protocol " + protocol);
    }

    return Collections.unmodifiableSet(enabledProtocols);
}

From source file:org.web4thejob.security.SpringSecurityContext.java

@Override
public void afterPropertiesSet() throws Exception {
    List<Element> elements = getAuthorizationElements();
    for (Element element : elements) {
        readRevokedResources(element);//from ww w . j  a v a 2s. co m
    }
    revokedResources = Collections.unmodifiableSet(revokedResources);
}

From source file:com.qwazr.server.configuration.ServerConfiguration.java

protected ServerConfiguration(final Map<?, ?>... propertiesMaps) throws IOException {

    // Merge the maps.
    properties = new HashMap<>();
    if (propertiesMaps != null) {
        for (Map<?, ?> props : propertiesMaps)
            if (props != null)
                props.forEach((key, value) -> {
                    if (key != null && value != null)
                        properties.put(key.toString(), value.toString());
                });/*w  w  w.j  a va  2  s .  c o m*/
    }

    //Set the data directory
    dataDirectory = getDataDirectory(getStringProperty(QWAZR_DATA, null));
    if (dataDirectory == null)
        throw new IOException("The data directory has not been set.");
    if (!Files.exists(dataDirectory))
        throw new IOException("The data directory does not exists: " + dataDirectory.toAbsolutePath());
    if (!Files.isDirectory(dataDirectory))
        throw new IOException("The data directory is not a directory: " + dataDirectory.toAbsolutePath());

    //Set the temp directory
    tempDirectory = getTempDirectory(dataDirectory, getStringProperty(QWAZR_TEMP, null));
    if (!Files.exists(tempDirectory))
        Files.createDirectories(tempDirectory);
    if (!Files.exists(tempDirectory))
        throw new IOException("The temp directory does not exists: " + tempDirectory.toAbsolutePath());
    if (!Files.isDirectory(tempDirectory))
        throw new IOException("The temp directory is not a directory: " + tempDirectory.toAbsolutePath());

    //Set the configuration directories
    etcDirectories = getEtcDirectories(getStringProperty(QWAZR_ETC_DIR, null));
    etcFileFilter = buildEtcFileFilter(getStringProperty(QWAZR_ETC, null));

    //Set the listen address
    listenAddress = findListenAddress(getStringProperty(LISTEN_ADDR, null));

    //Set the public address
    publicAddress = findPublicAddress(getStringProperty(PUBLIC_ADDR, null), this.listenAddress);

    //Set the connectors
    webAppConnector = new WebConnector(publicAddress, getIntegerProperty(WEBAPP_PORT, null), 9090,
            getStringProperty(WEBAPP_AUTHENTICATION, null), getStringProperty(WEBAPP_REALM, null));
    webServiceConnector = new WebConnector(publicAddress, getIntegerProperty(WEBSERVICE_PORT, null), 9091,
            getStringProperty(WEBSERVICE_AUTHENTICATION, null), getStringProperty(WEBSERVICE_REALM, null));
    multicastConnector = new WebConnector(getStringProperty(MULTICAST_ADDR, null),
            getIntegerProperty(MULTICAST_PORT, null), 9091, null, null);

    // Collect the master address.
    final LinkedHashSet<String> set = new LinkedHashSet<>();
    try {
        findMatchingAddress(getStringProperty(QWAZR_MASTERS, null), set);
    } catch (SocketException e) {
        LOGGER.warning("Failed in extracting IP information. No master server is configured.");
    }
    this.masters = set.isEmpty() ? null : Collections.unmodifiableSet(set);

    this.groups = buildSet(getStringProperty(QWAZR_GROUPS, null), ",; \t", true);
}

From source file:com.bigdata.dastor.dht.Range.java

private static Set<Range> intersectionOneWrapping(Range wrapping, Range other) {
    Set<Range> intersection = new HashSet<Range>(2);
    if (other.contains(wrapping.right))
        intersection.add(new Range(other.left, wrapping.right));
    // need the extra compareto here because ranges are asymmetrical; wrapping.left _is not_ contained by the wrapping range
    if (other.contains(wrapping.left) && wrapping.left.compareTo(other.right) < 0)
        intersection.add(new Range(wrapping.left, other.right));
    return Collections.unmodifiableSet(intersection);
}

From source file:net.sourceforge.fenixedu.domain.accounting.AccountingTransaction.java

@Override
public Set<AccountingTransaction> getAdjustmentTransactionsSet() {
    return Collections.unmodifiableSet(super.getAdjustmentTransactionsSet());
}

From source file:com.hmsinc.epicenter.model.analysis.AnalysisParameters.java

/**
 * @return the genders//from ww  w .  j  av a2  s .c o  m
 */
public Set<Gender> getGenders() {
    final Set<Gender> allGenders = new HashSet<Gender>();
    if (attributes != null) {
        for (Attribute a : attributes) {
            if (a instanceof Gender) {
                allGenders.add((Gender) a);
            }
        }
    }
    return Collections.unmodifiableSet(allGenders);
}

From source file:net.sourceforge.fenixedu.domain.Shift.java

@Override
public Set<StudentGroup> getAssociatedStudentGroupsSet() {
    Set<StudentGroup> result = new HashSet<StudentGroup>();
    for (StudentGroup sg : super.getAssociatedStudentGroupsSet()) {
        if (sg.getValid()) {
            result.add(sg);// w  w w  .ja  va2  s  .c o  m
        }
    }
    return Collections.unmodifiableSet(result);
}

From source file:com.nflabs.shiro.cache.zookeeper.ZookeeperCache.java

@Override
public Set<K> keys() {
    if (!isBaseDirectoryExist()) {
        LOG.debug("The Zookeeper base dir doesnt exist, abort.");
        return Collections.emptySet();
    }// www  .j  a  v a  2s  .  c  o m

    try {
        @SuppressWarnings("unchecked")
        List<K> childrens = (List<K>) zookeeperClient.getChildren(zookeeperBasePath, null);
        if (!CollectionUtils.isEmpty(childrens)) {
            return Collections.unmodifiableSet(new LinkedHashSet<K>(childrens));
        } else {
            return Collections.emptySet();
        }
    } catch (InterruptedException | KeeperException e) {
        //throw new CacheException(e);
        LOG.error("Error: {}", e.getMessage());
        return Collections.emptySet();
    }
}