Package net.solarnetwork.domain
Interface Bitmaskable
- All Known Subinterfaces:
GroupedBitmaskable
- All Known Implementing Classes:
DeviceOperatingState,GenericDeviceOperatingState,SkyCondition
public interface Bitmaskable
A standardized API for domain objects that can be represented in bitmask
form.
A bitmask is a collection of on/off flags encoded as bits within an integer value.
- Since:
- 1.50
- Version:
- 1.1
- Author:
- matt
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classSortBitmaskableinstances by type, then bit index. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<Bitmaskable>A comparator ofBitmaskableby their type (class name) then bit index, in ascending order. -
Method Summary
Modifier and TypeMethodDescriptionintGet the bit offset.static intbitmaskValue(Set<? extends Bitmaskable> maskables) Get a bitmask value for a set ofBitmaskableobjects.static <T extends Enum<T> & Bitmaskable>
Set<T>setForBitmask(int mask, Class<T> clazz) Convert a bitmask value into a set ofBitmaskableobjects.static <T extends Bitmaskable>
Set<T>setForBitmask(int mask, T[] values) Convert a bitmask value into a set ofBitmaskableobjects.
-
Field Details
-
SORT_BY_TYPE
A comparator ofBitmaskableby their type (class name) then bit index, in ascending order.- Since:
- 1.1
-
-
Method Details
-
bitmaskBitOffset
int bitmaskBitOffset()Get the bit offset.- Returns:
- offset, starting from 0 for the right-most bit
-
bitmaskValue
Get a bitmask value for a set ofBitmaskableobjects.- Parameters:
maskables- the set ofBitmaskableobjects (null allowed)- Returns:
- a bitmask value of all
bitmaskBitOffset()values of the givenmaskables - See Also:
-
setForBitmask
Convert a bitmask value into a set ofBitmaskableobjects.- Type Parameters:
T- the value type- Parameters:
mask- a bitmask value of a set ofBitmaskableobjectsclazz- the class of an enumeration ofBitmaskableobjects- Returns:
- an immutable set of
Bitmaskableobjects, never null - See Also:
-
setForBitmask
Convert a bitmask value into a set ofBitmaskableobjects.- Type Parameters:
T- the value type- Parameters:
mask- a bitmask value of a set ofBitmaskableobjectsvalues- the complete set of possibleBitmaskableobjects- Returns:
- an immutable set of
Bitmaskableobjects, never null - See Also:
-