Java Code Examples for java.util.Collections.unmodifiableSet()

The following are Jave code examples for showing how to use unmodifiableSet() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: AndroidMuseumBleManager   File: BluetoothLeDevice.java   View Source Code Vote up 6 votes
public Set<BluetoothService> getBluetoothDeviceKnownSupportedServices() {
    if (mServiceSet == null) {
        synchronized (this) {
            if (mServiceSet == null) {
                final Set<BluetoothService> serviceSet = new HashSet<>();
                for (final BluetoothService service : BluetoothService.values()) {

                    if (mDevice.getBluetoothClass().hasService(service.getAndroidConstant())) {
                        serviceSet.add(service);
                    }
                }
                mServiceSet = Collections.unmodifiableSet(serviceSet);
            }
        }
    }

    return mServiceSet;
}
 
Example 2
Project: wmboost-data   File: DocumentImpl.java   View Source Code Vote up 6 votes
public Collection<String> getKeys() {

		// Using LinkedHashSet to preserve insertion order
		Set<String> keys = new LinkedHashSet<String>();
		
		IDataCursorResource cursorRes = newCursorResource();
		try {
			IDataCursor cursor = cursorRes.getCursor();
			boolean hasMore = cursor.first();
			while (hasMore) {
				keys.add(cursor.getKey());

				hasMore = cursor.next();
			}
			return Collections.unmodifiableSet(keys);
		}
		finally {
			cursorRes.close();
		}
	}
 
Example 3
Project: koryphe   File: ReflectionUtil.java   View Source Code Vote up 6 votes
/**
 * Get implementations of a given class. The results are cached.
 *
 * @param clazz the class to get sub types of.
 * @return the sub classes.
 */
public static Set<Class> getSubTypes(final Class<?> clazz) {
    Set<Class> subClasses = subclassesCache.get(clazz);
    if (null == subClasses) {
        updateReflectionPackages();

        final Set<Class> newSubClasses = new HashSet<>();
        if (clazz.isInterface()) {
            getScanner().matchClassesImplementing(clazz, c -> {
                if (isPublicConcrete(c)) {
                    newSubClasses.add(c);
                }
            }).scan();
        } else {
            getScanner().matchSubclassesOf(clazz, c -> {
                if (isPublicConcrete(c)) {
                    newSubClasses.add(c);
                }
            }).scan();
        }
        subClasses = Collections.unmodifiableSet(newSubClasses);
        subclassesCache.put(clazz, subClasses);
    }

    return subClasses;
}
 
Example 4
Project: Tarski   File: MagicUtil.java   View Source Code Vote up 6 votes
/** Returns every top-level user type that is itself visible or has a visible subtype.
 * @param vizState
 */
static Set<AlloyType> partiallyVisibleUserTopLevelTypes(final VizState vizState) {
   final AlloyModel model = vizState.getOriginalModel();
   final Set<AlloyType> visibleUserTypes = visibleUserTypes(vizState);
   //final Set<AlloyType> topLevelTypes = topLevelTypes(vizState);

   final Set<AlloyType> result = new LinkedHashSet<AlloyType>();

   for (final AlloyType t : visibleUserTypes) {
      if (visibleUserTypes.contains(t)) {
         result.add(model.getTopmostSuperType(t));
      }
   }

   return Collections.unmodifiableSet(result);
}
 
Example 5
Project: hybris-integration-intellij-idea-plugin   File: AbstractHybrisModuleDescriptor.java   View Source Code Vote up 5 votes
@NotNull
@Override
public Set<HybrisModuleDescriptor> getDependenciesPlainList() {
    return Collections.unmodifiableSet(this.recursivelyCollectDependenciesPlainSet(
        this, new TreeSet<>()
    ));
}
 
Example 6
Project: OpenJSharp   File: SchemaDocumentImpl.java   View Source Code Vote up 5 votes
public Set<SchemaDocument> getImportedDocuments(String targetNamespace) {
    if(targetNamespace==null)
        throw new IllegalArgumentException();
    Set<SchemaDocument> r = new HashSet<SchemaDocument>();
    for (SchemaDocumentImpl doc : references) {
        if(doc.getTargetNamespace().equals(targetNamespace))
            r.add(doc);
    }
    return Collections.unmodifiableSet(r);
}
 
Example 7
Project: GitHub   File: LruBitmapPool.java   View Source Code Vote up 5 votes
@TargetApi(Build.VERSION_CODES.O)
private static Set<Bitmap.Config> getDefaultAllowedConfigs() {
  Set<Bitmap.Config> configs = new HashSet<>();
  configs.addAll(Arrays.asList(Bitmap.Config.values()));
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    // GIFs, among other types, end up with a native Bitmap config that doesn't map to a java
    // config and is treated as null in java code. On KitKat+ these Bitmaps can be reconfigured
    // and are suitable for re-use.
    configs.add(null);
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
    configs.remove(Bitmap.Config.HARDWARE);
  }
  return Collections.unmodifiableSet(configs);
}
 
Example 8
Project: OpenJSharp   File: PropertyHashMap.java   View Source Code Vote up 5 votes
@Override
public Set<Entry<String, Property>> entrySet() {
    final HashSet<Entry<String, Property>> set = new HashSet<>();
    for (Element element = list; element != null; element = element.getLink()) {
        set.add(element);
    }
    return Collections.unmodifiableSet(set);
}
 
Example 9
Project: monarch   File: PartitionedRegionDataStore.java   View Source Code Vote up 5 votes
/**
 * Returns a set of local buckets.
 * 
 * @return an unmodifiable set of BucketRegion
 */
public Set<BucketRegion> getAllLocalBucketRegions() {
  Set<BucketRegion> retVal = new HashSet<BucketRegion>();
  for (BucketRegion br : localBucket2RegionMap.values()) {
    retVal.add(br);
  }
  return Collections.unmodifiableSet(retVal);
}
 
Example 10
Project: azure-libraries-for-java   File: DiskImpl.java   View Source Code Vote up 5 votes
@Override
public Set<AvailabilityZoneId> availabilityZones() {
    Set<AvailabilityZoneId> zones = new HashSet<>();
    if (this.inner().zones() != null) {
        for (String zone : this.inner().zones()) {
            zones.add(AvailabilityZoneId.fromString(zone));
        }
    }
    return Collections.unmodifiableSet(zones);
}
 
Example 11
Project: incubator-netbeans   File: SourceRootsCache.java   View Source Code Vote up 5 votes
private static Set<File> getCanonicalFiles(String[] paths) {
    Set<File> files = new HashSet<>(paths.length);
    for (String root : paths) {
        File rootFile = new File(root);
        try {
            rootFile = rootFile.getCanonicalFile();
        } catch (IOException ioex) {}
        files.add(rootFile);
    }
    return Collections.unmodifiableSet(files);
}
 
Example 12
Project: lams   File: DeploymentInfo.java   View Source Code Vote up 4 votes
public Set<String> getSecurityRoles() {
    return Collections.unmodifiableSet(securityRoles);
}
 
Example 13
Project: jdk8u-jdk   File: Sockets.java   View Source Code Vote up 4 votes
private static void initOptionSets() {
    boolean flowsupported = ExtendedOptionsImpl.flowSupported();

    // Socket

    Set<SocketOption<?>> set = new HashSet<>();
    set.add(StandardSocketOptions.SO_KEEPALIVE);
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.SO_LINGER);
    set.add(StandardSocketOptions.IP_TOS);
    set.add(StandardSocketOptions.TCP_NODELAY);
    if (flowsupported) {
        set.add(ExtendedSocketOptions.SO_FLOW_SLA);
    }
    set = Collections.unmodifiableSet(set);
    options.put(Socket.class, set);

    // ServerSocket

    set = new HashSet<>();
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.IP_TOS);
    set = Collections.unmodifiableSet(set);
    options.put(ServerSocket.class, set);

    // DatagramSocket

    set = new HashSet<>();
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.IP_TOS);
    if (flowsupported) {
        set.add(ExtendedSocketOptions.SO_FLOW_SLA);
    }
    set = Collections.unmodifiableSet(set);
    options.put(DatagramSocket.class, set);

    // MulticastSocket

    set = new HashSet<>();
    set.add(StandardSocketOptions.SO_SNDBUF);
    set.add(StandardSocketOptions.SO_RCVBUF);
    set.add(StandardSocketOptions.SO_REUSEADDR);
    set.add(StandardSocketOptions.IP_TOS);
    set.add(StandardSocketOptions.IP_MULTICAST_IF);
    set.add(StandardSocketOptions.IP_MULTICAST_TTL);
    set.add(StandardSocketOptions.IP_MULTICAST_LOOP);
    if (flowsupported) {
        set.add(ExtendedSocketOptions.SO_FLOW_SLA);
    }
    set = Collections.unmodifiableSet(set);
    options.put(MulticastSocket.class, set);
}
 
Example 14
Project: dubbox-hystrix   File: MockedChannelHandler.java   View Source Code Vote up 4 votes
public Set<Channel> getChannels(){
    return Collections.unmodifiableSet(channels);
}
 
Example 15
Project: dubbocloud   File: RegistryContainer.java   View Source Code Vote up 4 votes
public Set<String> getApplications() {
    return Collections.unmodifiableSet(applications);
}
 
Example 16
Project: incubator-netbeans   File: WhiteListCategoryPanelTest.java   View Source Code Vote up 4 votes
@Override
public Iterable<String> listKeys(boolean shared) {
    final Map<String,String> map = shared ? projProp : privProp;
    return Collections.unmodifiableSet(new HashSet<String>(map.keySet()));
}
 
Example 17
Project: powsybl-core   File: SubstationImpl.java   View Source Code Vote up 4 votes
@Override
public Iterable<VoltageLevel> getVoltageLevels() {
    return Collections.unmodifiableSet(voltageLevels);
}
 
Example 18
Project: vxrifa   File: VxRifaAnnotationProcessor.java   View Source Code Vote up 3 votes
@Override
public Set<String> getSupportedAnnotationTypes() {

    HashSet<String> annotations = new HashSet<>();

    annotations.add(VxRifa.class.getCanonicalName());
    annotations.add(VxRifaPublish.class.getCanonicalName());

    return Collections.unmodifiableSet(annotations);

}
 
Example 19
Project: OpenJSharp   File: DateTimeFormatter.java   View Source Code Vote up 3 votes
/**
 * Returns a copy of this formatter with a new set of resolver fields.
 * <p>
 * This returns a formatter with similar state to this formatter but with
 * the resolver fields set. By default, a formatter has no resolver fields.
 * <p>
 * Changing the resolver fields only has an effect during parsing.
 * Parsing a text string occurs in two phases.
 * Phase 1 is a basic text parse according to the fields added to the builder.
 * Phase 2 resolves the parsed field-value pairs into date and/or time objects.
 * The resolver fields are used to filter the field-value pairs between phase 1 and 2.
 * <p>
 * This can be used to select between two or more ways that a date or time might
 * be resolved. For example, if the formatter consists of year, month, day-of-month
 * and day-of-year, then there are two ways to resolve a date.
 * Calling this method with the arguments {@link ChronoField#YEAR YEAR} and
 * {@link ChronoField#DAY_OF_YEAR DAY_OF_YEAR} will ensure that the date is
 * resolved using the year and day-of-year, effectively meaning that the month
 * and day-of-month are ignored during the resolving phase.
 * <p>
 * In a similar manner, this method can be used to ignore secondary fields that
 * would otherwise be cross-checked. For example, if the formatter consists of year,
 * month, day-of-month and day-of-week, then there is only one way to resolve a
 * date, but the parsed value for day-of-week will be cross-checked against the
 * resolved date. Calling this method with the arguments {@link ChronoField#YEAR YEAR},
 * {@link ChronoField#MONTH_OF_YEAR MONTH_OF_YEAR} and
 * {@link ChronoField#DAY_OF_MONTH DAY_OF_MONTH} will ensure that the date is
 * resolved correctly, but without any cross-check for the day-of-week.
 * <p>
 * In implementation terms, this method behaves as follows. The result of the
 * parsing phase can be considered to be a map of field to value. The behavior
 * of this method is to cause that map to be filtered between phase 1 and 2,
 * removing all fields other than those specified as arguments to this method.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param resolverFields  the new set of resolver fields, null if no fields
 * @return a formatter based on this formatter with the requested resolver style, not null
 */
public DateTimeFormatter withResolverFields(TemporalField... resolverFields) {
    Set<TemporalField> fields = null;
    if (resolverFields != null) {
        fields = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(resolverFields)));
    }
    if (Objects.equals(this.resolverFields, fields)) {
        return this;
    }
    return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, fields, chrono, zone);
}
 
Example 20
Project: dacapobench   File: Config.java   View Source Code Vote up 2 votes
/**
 * Get the collection of sizes this benchmark accepts
 * 
 * @return A collection of strings
 */
public Collection<String> getSizes() {
  return Collections.unmodifiableSet(sizes.keySet());
}