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:libepg.epg.section.sectionreconstructor.SectionReconstructor.java

/**
 * getSectionByteArrays()??????????CRC????????
 *
 * @return ?/*from w w  w .  j  a  va  2s  . c  o m*/
 */
public synchronized Set<Section> getSections() {
    Set<byte[]> section_byte = this.getSectionByteArrays();
    Set<Section> ret = new HashSet<>();
    for (byte[] b : section_byte) {
        final Section sec;
        Section s_t = null;
        try {
            s_t = new Section(b);
        } catch (IllegalArgumentException e) {
            LOG.warn(
                    "??????????????",
                    e);
            s_t = null;
        } finally {
            sec = s_t;
        }
        if (sec != null) {
            if (sec.checkCRC() == CRC_STATUS.NO_CRC_ERROR) {
                ret.add(sec);
            } else {
                LOG.warn("CRC?????????????");
            }
        }
    }
    return Collections.unmodifiableSet(ret);
}

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

public RegisterFeedTables() {
    final Set<Relationship> r = new HashSet<>();
    r.add(REL_SUCCESS);/*from  w  w  w  . j a  v a2s .  co m*/
    r.add(REL_FAILURE);
    relationships = Collections.unmodifiableSet(r);

    final List<PropertyDescriptor> pds = new ArrayList<>();
    pds.add(THRIFT_SERVICE);
    pds.add(FEED_CATEGORY);
    pds.add(FEED_NAME);
    pds.add(TABLE_TYPE);
    pds.add(FIELD_SPECIFICATION);
    pds.add(PARTITION_SPECS);
    pds.add(FEED_FIELD_SPECIFICATION);
    pds.add(FEED_FORMAT_SPECS);
    pds.add(TARGET_FORMAT_SPECS);
    pds.add(TARGET_TBLPROPERTIES);
    pds.add(FEED_ROOT);
    pds.add(PROFILE_ROOT);
    pds.add(MASTER_ROOT);

    propDescriptors = Collections.unmodifiableList(pds);
}

From source file:edu.uci.ics.jung.utils.SubsetManager.java

/**
 * Returns the edge subset, if any, which this instance has defined
 * based on <code>p</code>.  If this instance has defined no such
 * subset, returns null./* w ww .ja  va  2 s  .c  om*/
 * @param p     the predicate which may define a subset
 */
public Set getEdges(Predicate p) {
    Set s = (Set) getEdgeMap().get(p);
    if (s != null)
        return Collections.unmodifiableSet(s);
    else
        return null;
}

From source file:com.bah.alter.PutGeowave.java

@Override
protected void init(final ProcessorInitializationContext context) {
    final List<PropertyDescriptor> descriptors = new ArrayList<PropertyDescriptor>();
    descriptors.add(ZOOKEEPERS);/* w w  w. ja  v  a 2  s . com*/
    descriptors.add(ACCUMULO_INSTANCE);
    descriptors.add(ACCUMULO_USERNAME);
    descriptors.add(ACCUMULO_PASSWORD);
    descriptors.add(GEOWAVE_NAMESPACE);
    this.descriptors = Collections.unmodifiableList(descriptors);

    final Set<Relationship> relationships = new HashSet<Relationship>();
    relationships.add(SUCCESS);
    relationships.add(FAILURE);
    this.relationships = Collections.unmodifiableSet(relationships);

}

From source file:org.openwms.core.uaa.Role.java

/**
 * Return an unmodifiable Set of all {@link User}s assigned to the Role.
 *
 * @return A Set of all {@link User}s assigned to the Role
 *///  w w  w .  ja v  a2s .  c  o  m
public Set<User> getUsers() {
    return Collections.unmodifiableSet(users);
}

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

/**
 * @return the ageGroups//ww  w  .  ja v a 2s . co m
 */
public Set<AgeGroup> getAgeGroups() {
    final Set<AgeGroup> allAgeGroups = new HashSet<AgeGroup>();
    if (attributes != null) {
        for (Attribute a : attributes) {
            if (a instanceof AgeGroup) {
                allAgeGroups.add((AgeGroup) a);
            }
        }
    }
    return Collections.unmodifiableSet(allAgeGroups);
}

From source file:dumptspacket.Main.java

public void start(String[] args) throws org.apache.commons.cli.ParseException {
    final String fileName;
    final Long limit;
    final Set<Integer> pids;

    System.out.println("args   : " + dumpArgs(args));

    final Option fileNameOption = Option.builder("f").required().longOpt("filename").desc("ts??")
            .hasArg().type(String.class).build();

    final Option limitOption = Option.builder("l").required(false).longOpt("limit")
            .desc("??(???????EOF??)").hasArg()
            .type(Long.class).build();

    final Option pidsOption = Option.builder("p").required().longOpt("pids")
            .desc("pid(?16?)").type(String.class).hasArgs().build();

    Options opts = new Options();
    opts.addOption(fileNameOption);//from   w  ww.j a v a 2 s .  c  o  m
    opts.addOption(limitOption);
    opts.addOption(pidsOption);
    CommandLineParser parser = new DefaultParser();
    CommandLine cl;
    HelpFormatter help = new HelpFormatter();

    try {

        // parse options
        cl = parser.parse(opts, args);

        // handle interface option.
        fileName = cl.getOptionValue(fileNameOption.getOpt());
        if (fileName == null) {
            throw new ParseException("????????");
        }

        // handlet destination option.
        Long xl = null;
        try {
            xl = Long.parseUnsignedLong(cl.getOptionValue(limitOption.getOpt()));
        } catch (NumberFormatException e) {
            xl = null;
        } finally {
            limit = xl;
        }

        Set<Integer> x = new HashSet<>();
        List<String> ls = new ArrayList<>();
        ls.addAll(Arrays.asList(cl.getOptionValues(pidsOption.getOpt())));
        for (String s : ls) {
            try {
                x.add(Integer.parseUnsignedInt(s, 16));
            } catch (NumberFormatException e) {
                throw new ParseException(e.getMessage());
            }
        }
        pids = Collections.unmodifiableSet(x);

        System.out.println("Starting application...");
        System.out.println("filename   : " + fileName);
        System.out.println("limit : " + limit);
        System.out.println("pids : " + dumpSet(pids));

        // your code
        TsReader reader;
        if (limit == null) {
            reader = new TsReader(new File(fileName), pids);
        } else {
            reader = new TsReader(new File(fileName), pids, limit);
        }

        Map<Integer, List<TsPacketParcel>> ret = reader.getPackets();
        try {
            for (Integer pid : ret.keySet()) {

                FileWriter writer = new FileWriter(fileName + "_" + Integer.toHexString(pid) + ".txt");

                for (TsPacketParcel par : ret.get(pid)) {
                    String text = Hex.encodeHexString(par.getPacket().getData());
                    writer.write(text + "\n");

                }
                writer.flush();
                writer.close();
            }
        } catch (IOException ex) {
            LOG.fatal("", ex);
        }

    } catch (ParseException e) {
        // print usage.
        help.printHelp("My Java Application", opts);
        throw e;
    } catch (FileNotFoundException ex) {
        LOG.fatal("", ex);
    }
}

From source file:de.cosmocode.palava.model.geoplanet.Place.java

@Override
public Set<Alias> getAliases() {
    return Collections.unmodifiableSet(aliases);
}

From source file:lodsve.core.condition.ConditionEvaluationReport.java

/**
 * Returns the names of the classes that were evaluated but were not conditional.
 *
 * @return the names of the unconditional classes
 *///from   w  w  w  .jav  a2s  .  c  o m
public Set<String> getUnconditionalClasses() {
    return Collections.unmodifiableSet(this.unconditionalClasses);
}

From source file:de.decoit.simu.cbor.ifmap.metadata.multivalue.CBORLocation.java

/**
 * Returns an immutable view of the localtion information set.
 *
 * @return Immutable set view/* w  w w  .  j a  v  a 2 s .com*/
 */
public Set<LocationInformation> getLocationInformation() {
    return Collections.unmodifiableSet(this.locationInformation);
}