Create a unmodifiable set with contents.
@param contents The contents of the set.
@return A unmodifiable set containing contents.
358168
public static <T> Set<T> newUnmodifiableSet(Collection<T> contents)
	{
		if(isEmpty(contents))
			return Collections.emptySet();
		if(contents.size() == 1)
			return Collections.singleton(contents.iterator().next());
		return Collections.unmodifiableSet(dup(contents));
	}
675768
public Message contentEncoding(String charset) {
        basicProperties = basicProperties.builder()
                .contentEncoding(charset)
                .build();
        return this;
    }
994982
@Override
    public Set<K> keySet() {
        final Set<K> localSet = this.localMap.keySet();

        if (isReadyOnly())
            return Collections.unmodifiableSet(localSet);

        return localSet;
    }
765015
@Nonnull
  public final UnifiedResponse setContentAndCharset (@Nonnull final String sContent, @Nonnull final Charset aCharset)
  {
    ValueEnforcer.notNull (sContent, "Content");
    setCharset (aCharset);
    setContent (sContent.getBytes (aCharset));
    return this;
  }
140839
public static <T> Set<T> append(Set<T> readonly, T obj)
    {
        Set<T> writable = readonly != null ? new HashSet<>(readonly) : new HashSet<>();

        writable.add(obj);

        return writable;
    }
1161265
public static <T> Set<T> iterableToSet(Iterable<T> iterable) {
        if (iterable == null) {
            return Collections.emptySet();
        }
        if (iterable instanceof Set) {
            return (Set<T>) iterable;
        }
        Iterator<T> i = iterable.iterator();
        if (i.hasNext()) {
            Set<T> list = new HashSet<>();
            while (i.hasNext()) {
                list.add(i.next());
            }
            return list;
        }
        return Collections.emptySet();
    }
488951
public static <T> Set<T> nullToEmpty(final Set<T> set) {
        return set == null ? N.<T> emptySet() : set;
    }
1290336
private static <K, V> void makeSetsImmutable(Map<K, Set<V>> map) {
    Set<K> keys = map.keySet();
    for (K key : keys) {
      Set<V> value = map.get(key);
      map.put(key, Collections.unmodifiableSet(value));
    }
  }
898332
@Inline(value="$2.$3copyOf($1)", imported=ImmutableSet.class)
	public static <T> Set<T> immutableCopy(Set<? extends T> set) {
		return ImmutableSet.copyOf(set);
	}
196748
public void setContent(Object content, String contentType)
			throws UnsupportedEncodingException {
		// https://code.google.com/p/sipservlets/issues/detail?id=202
		if(getSipSession().getProxy() == null) {
			checkMessageState();
		}
		checkContentType(contentType);
		checkCommitted();

		if(contentType != null && contentType.length() > 0) {
			this.addHeader(ContentTypeHeader.NAME, contentType);
			ContentTypeHeader contentTypeHeader = (ContentTypeHeader)this.message.getHeader(ContentTypeHeader.NAME);
			String charset = this.getCharacterEncoding();
			try {
			    // https://code.google.com/p/sipservlets/issues/detail?id=169
				if(contentType.contains(CONTENT_TYPE_MULTIPART) && content instanceof Multipart) {
					// Fix for Issue 2667 : Correct Handling of MimeMultipart
					Multipart multipart = (Multipart) content;
					OutputStream os = new ByteArrayOutputStream();
					multipart.writeTo(os);
					this.message.setContent(os.toString(), contentTypeHeader);
				} else {
					Object tmpContent = content;
					if(tmpContent instanceof String  && charset != null) {
						//test for unsupportedencoding exception
						new String("testEncoding".getBytes(charset));
						tmpContent = new String(((String)tmpContent).getBytes());
					}
					this.message.setContent(content, contentTypeHeader);
				}
			} catch (UnsupportedEncodingException uee) {
				throw uee;
			} catch (Exception e) {
				throw new IllegalArgumentException("Parse error reading content " + content + " with content type " + contentType, e);
			}
		}
	}
914844
public void setContents(ByteArraySegment contents) {
        Preconditions.checkNotNull(contents, "contents");
        Preconditions.checkState(this.contents == null, "This operation has already had its contents set.");
        this.contents = contents;
    }
1013611
public final void setContent(String content)
    {
        //clear non relevant flags
        this.contentBinary=null;
        this.contentParts=null;
        this.contentType=ContentType.STRING;

        this.contentString=content;
    }
114330
public static byte[] gzip(String content, String charset) throws UtilException {
		return gzip(StrUtil.bytes(content, charset));
	}
843897
public Response andContent(Map<String, Object> content) {
        Objects.requireNonNull(content, Required.CONTENT.toString());
        this.content.putAll(content);

        return this;
    }
1297568
public void setBody(byte[] contents) {
		if (contents == null) {
			return;
		}
		cachedString = null;
		
		body = new byte[contents.length];
		System.arraycopy(contents, 0, body, 0, contents.length);
		
		pos = body.length;
	}
1302964
@SafeVarargs
    public static <T> Set<T> of(T... elements) {
        Preconditions.checkNotNull(elements);
        return ImmutableSet.<T> builder().addAll(elements).build();
    }
501174
public static <T> Set<T> copy(final Set<T> set) {
		if (set == null) {
			return null;
		}

		TypeEnum elementType = null;
		Set<T> copy = new HashSet<T>();
		for (T element : set) {
			T elementCopy = null;
			if (element != null) {
				if (elementType == null) {
					elementType = TypeEnum.dataTypeOf(element.getClass());
				}
				elementCopy = copy(element, elementType);
			}

			copy.add(elementCopy);
		}

		return copy;
	}