@UnstableApi
public final class FlagSet


A set of integer flags.

Intended for usages where the number of flags may exceed 32 and can no longer be represented by an IntDef.

Instances are immutable.

Summary

Nested types

public final class FlagSet.Builder

A builder for FlagSet instances.

Public methods

boolean
contains(int flag)

Returns whether the set contains the given flag.

boolean
containsAny(int[] flags)

Returns whether the set contains at least one of the given flags.

boolean
int
get(int index)

Returns the flag at the given index.

int
int

Returns the number of flags in this set.

Public methods

contains

public boolean contains(int flag)

Returns whether the set contains the given flag.

Parameters
int flag

The flag.

Returns
boolean

Whether the set contains the flag.

containsAny

public boolean containsAny(int[] flags)

Returns whether the set contains at least one of the given flags.

Parameters
int[] flags

The flags.

Returns
boolean

Whether the set contains at least one of the flags.

equals

public boolean equals(@Nullable Object o)

get

public int get(int index)

Returns the flag at the given index.

Parameters
int index

The index. Must be between 0 (inclusive) and size (exclusive).

Returns
int

The flag at the given index.

Throws
java.lang.IndexOutOfBoundsException

If index is outside the allowed range.

hashCode

public int hashCode()

size

public int size()

Returns the number of flags in this set.