Fix SAT warnings (#14202)
* Fix SAT warnings - checkstyle.ModifierOrderCheck - checkstyle.OneStatementPerLineCheck - checkstyle.NeedBracesCheck - PMD.UseStandardCharsets - PMD.UseCollectionIsEmpty - PMD.UnusedLocalVariable - PMD.SimplifyBooleanReturns where reasonable, suppress where readability is better without change - PMD.SimplifyBooleanExpressions * Include StandardCharsets Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
@@ -60,9 +60,9 @@ import io.github.hapjava.server.impl.HomekitRoot;
|
||||
@NonNullByDefault
|
||||
public class HomekitChangeListener implements ItemRegistryChangeListener {
|
||||
private final Logger logger = LoggerFactory.getLogger(HomekitChangeListener.class);
|
||||
private final static String REVISION_CONFIG = "revision";
|
||||
private final static String ACCESSORY_COUNT = "accessory_count";
|
||||
private final static String KNOWN_ACCESSORIES = "known_accessories";
|
||||
private static final String REVISION_CONFIG = "revision";
|
||||
private static final String ACCESSORY_COUNT = "accessory_count";
|
||||
private static final String KNOWN_ACCESSORIES = "known_accessories";
|
||||
private final ItemRegistry itemRegistry;
|
||||
private final HomekitAccessoryRegistry accessoryRegistry = new HomekitAccessoryRegistry();
|
||||
private final MetadataRegistry metadataRegistry;
|
||||
@@ -291,7 +291,6 @@ public class HomekitChangeListener implements ItemRegistryChangeListener {
|
||||
|
||||
try {
|
||||
boolean changed = false;
|
||||
boolean removed = false;
|
||||
for (final String name : pendingUpdates) {
|
||||
String oldValue = knownAccessories.get(name);
|
||||
accessoryRegistry.remove(name);
|
||||
|
||||
@@ -66,6 +66,7 @@ public class HomekitSettings {
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("PMD.SimplifyBooleanReturns")
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
|
||||
@@ -50,18 +50,18 @@ public class HomekitTaggedItem {
|
||||
private final Logger logger = LoggerFactory.getLogger(HomekitTaggedItem.class);
|
||||
|
||||
/** configuration keywords at items level **/
|
||||
public final static String DELAY = "commandDelay";
|
||||
public final static String DIMMER_MODE = "dimmerMode";
|
||||
public static final String DELAY = "commandDelay";
|
||||
public static final String DIMMER_MODE = "dimmerMode";
|
||||
public static final String BATTERY_LOW_THRESHOLD = "lowThreshold";
|
||||
public final static String INSTANCE = "instance";
|
||||
public final static String INVERTED = "inverted";
|
||||
public final static String MAX_VALUE = "maxValue";
|
||||
public final static String MIN_VALUE = "minValue";
|
||||
public final static String PRIMARY_SERVICE = "primary";
|
||||
public final static String STEP = "step";
|
||||
public final static String UNIT = "unit";
|
||||
public final static String EMULATE_STOP_STATE = "stop";
|
||||
public final static String EMULATE_STOP_SAME_DIRECTION = "stopSameDirection";
|
||||
public static final String INSTANCE = "instance";
|
||||
public static final String INVERTED = "inverted";
|
||||
public static final String MAX_VALUE = "maxValue";
|
||||
public static final String MIN_VALUE = "minValue";
|
||||
public static final String PRIMARY_SERVICE = "primary";
|
||||
public static final String STEP = "step";
|
||||
public static final String UNIT = "unit";
|
||||
public static final String EMULATE_STOP_STATE = "stop";
|
||||
public static final String EMULATE_STOP_SAME_DIRECTION = "stopSameDirection";
|
||||
|
||||
private static final Map<Integer, String> CREATED_ACCESSORY_IDS = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
@@ -63,10 +63,10 @@ import io.github.hapjava.characteristics.impl.common.NameCharacteristic;
|
||||
@NonNullByDefault
|
||||
public class HomekitAccessoryFactory {
|
||||
private static final Logger logger = LoggerFactory.getLogger(HomekitAccessoryFactory.class);
|
||||
public final static String METADATA_KEY = "homekit"; // prefix for HomeKit meta information in items.xml
|
||||
public static final String METADATA_KEY = "homekit"; // prefix for HomeKit meta information in items.xml
|
||||
|
||||
/** List of mandatory attributes for each accessory type. **/
|
||||
private final static Map<HomekitAccessoryType, HomekitCharacteristicType[]> MANDATORY_CHARACTERISTICS = new HashMap<HomekitAccessoryType, HomekitCharacteristicType[]>() {
|
||||
private static final Map<HomekitAccessoryType, HomekitCharacteristicType[]> MANDATORY_CHARACTERISTICS = new HashMap<HomekitAccessoryType, HomekitCharacteristicType[]>() {
|
||||
{
|
||||
put(ACCESSORY_GROUP, new HomekitCharacteristicType[] {});
|
||||
put(LEAK_SENSOR, new HomekitCharacteristicType[] { LEAK_DETECTED_STATE });
|
||||
@@ -112,7 +112,7 @@ public class HomekitAccessoryFactory {
|
||||
};
|
||||
|
||||
/** List of service implementation for each accessory type. **/
|
||||
private final static Map<HomekitAccessoryType, Class<? extends AbstractHomekitAccessoryImpl>> SERVICE_IMPL_MAP = new HashMap<HomekitAccessoryType, Class<? extends AbstractHomekitAccessoryImpl>>() {
|
||||
private static final Map<HomekitAccessoryType, Class<? extends AbstractHomekitAccessoryImpl>> SERVICE_IMPL_MAP = new HashMap<HomekitAccessoryType, Class<? extends AbstractHomekitAccessoryImpl>>() {
|
||||
{
|
||||
put(ACCESSORY_GROUP, HomekitAccessoryGroupImpl.class);
|
||||
put(LEAK_SENSOR, HomekitLeakSensorImpl.class);
|
||||
@@ -436,8 +436,9 @@ public class HomekitAccessoryFactory {
|
||||
MetadataRegistry metadataRegistry, HomekitAccessoryUpdater updater, HomekitSettings settings,
|
||||
Set<HomekitTaggedItem> ancestorServices) throws HomekitException {
|
||||
final var item = taggedItem.getItem();
|
||||
if (!(item instanceof GroupItem))
|
||||
if (!(item instanceof GroupItem)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var groupMember : ((GroupItem) item).getMembers().stream()
|
||||
.sorted((lhs, rhs) -> lhs.getName().compareTo(rhs.getName())).collect(Collectors.toList())) {
|
||||
@@ -446,8 +447,9 @@ public class HomekitAccessoryFactory {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
logger.trace("accessory types for {} are {}", groupMember.getName(), accessoryTypes);
|
||||
if (accessoryTypes.isEmpty())
|
||||
if (accessoryTypes.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (accessoryTypes.size() > 1) {
|
||||
logger.warn("Item {} is a HomeKit sub-accessory, but multiple accessory types are not allowed.",
|
||||
|
||||
@@ -162,7 +162,7 @@ public class HomekitCharacteristicFactory {
|
||||
private static final Logger logger = LoggerFactory.getLogger(HomekitCharacteristicFactory.class);
|
||||
|
||||
// List of optional characteristics and corresponding method to create them.
|
||||
private final static Map<HomekitCharacteristicType, BiFunction<HomekitTaggedItem, HomekitAccessoryUpdater, Characteristic>> optional = new HashMap<HomekitCharacteristicType, BiFunction<HomekitTaggedItem, HomekitAccessoryUpdater, Characteristic>>() {
|
||||
private static final Map<HomekitCharacteristicType, BiFunction<HomekitTaggedItem, HomekitAccessoryUpdater, Characteristic>> optional = new HashMap<HomekitCharacteristicType, BiFunction<HomekitTaggedItem, HomekitAccessoryUpdater, Characteristic>>() {
|
||||
{
|
||||
put(NAME, HomekitCharacteristicFactory::createNameCharacteristic);
|
||||
put(BATTERY_LOW_STATUS, HomekitCharacteristicFactory::createStatusLowBatteryCharacteristic);
|
||||
|
||||
@@ -32,7 +32,7 @@ import io.github.hapjava.services.impl.HumiditySensorService;
|
||||
* @author Andy Lintner - Initial contribution
|
||||
*/
|
||||
public class HomekitHumiditySensorImpl extends AbstractHomekitAccessoryImpl implements HumiditySensorAccessory {
|
||||
private final static String CONFIG_MULTIPLICATOR = "homekitMultiplicator";
|
||||
private static final String CONFIG_MULTIPLICATOR = "homekitMultiplicator";
|
||||
|
||||
public HomekitHumiditySensorImpl(HomekitTaggedItem taggedItem, List<HomekitTaggedItem> mandatoryCharacteristics,
|
||||
HomekitAccessoryUpdater updater, HomekitSettings settings) {
|
||||
|
||||
Reference in New Issue
Block a user