Skip to content

Commit

Permalink
Fixed SAT warnings.
Browse files Browse the repository at this point in the history
Signed-off-by: Hilbrand Bouwkamp <[email protected]>
  • Loading branch information
Hilbrand committed Apr 3, 2019
1 parent 96ed771 commit 2e7f450
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@
*/
package org.openhab.binding.dsmr.internal.device;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* Interface for classes controlling DSMR devices.
*
* @author Hilbrand Bouwkamp - Initial contribution
*/
@NonNullByDefault
public interface DSMRDevice {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.library.types.DateTimeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -30,6 +31,7 @@
* @author M. Volaart - Initial contribution
* @author Hilbrand Bouwkamp - Class now a factory instead of data containing class
*/
@NonNullByDefault
class CosemDate extends CosemValueDescriptor<DateTimeType> {

public static final CosemDate INSTANCE = new CosemDate("timestamp");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.text.ParseException;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.library.types.DecimalType;

/**
Expand All @@ -22,6 +23,7 @@
* @author M. Volaart - Initial contribution
* @author Hilbrand Bouwkamp - Combined Integer and Double because {@link DecimalType} handles both
*/
@NonNullByDefault
class CosemDecimal extends CosemValueDescriptor<DecimalType> {

public static final CosemDecimal INSTANCE = new CosemDecimal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.text.ParseException;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.library.types.StringType;

/**
Expand All @@ -22,6 +23,7 @@
* @author M. Volaart - Initial contribution
* @author Hilbrand Bouwkamp - Class now a factory instead of data containing class
*/
@NonNullByDefault
class CosemHexString extends CosemValueDescriptor<StringType> {

public static final CosemHexString INSTANCE = new CosemHexString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.types.State;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -28,6 +29,7 @@
*
* @author M. Volaart - Initial contribution
*/
@NonNullByDefault
public class CosemObject {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.util.List;
import java.util.Map;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -26,6 +28,7 @@
*
* @author M. Volaart - Initial contribution
*/
@NonNullByDefault
public class CosemObjectFactory {
private final Logger logger = LoggerFactory.getLogger(CosemObjectFactory.class);

Expand Down Expand Up @@ -84,7 +87,7 @@ public CosemObjectFactory() {
* @param cosemStringValues String containing Cosem values
* @return CosemObject or null if parsing failed
*/
public CosemObject getCosemObject(String obisIdString, String cosemStringValues) {
public @Nullable CosemObject getCosemObject(String obisIdString, String cosemStringValues) {
OBISIdentifier obisId;
OBISIdentifier reducedObisId;

Expand Down Expand Up @@ -112,7 +115,7 @@ public CosemObject getCosemObject(String obisIdString, String cosemStringValues)
cosemObject = getCosemObjectInternal(obisMsgType, obisId, cosemStringValues);
if (cosemObject != null) {
logger.trace("Searched reducedObisId {} in the wild card type list, result: {}", reducedObisId,
cosemObject);
cosemObject);
obisLookupTableDynamic.put(reducedObisId, obisMsgType);
break;
}
Expand All @@ -136,8 +139,8 @@ public CosemObject getCosemObject(String obisIdString, String cosemStringValues)
*
* @return a CosemObject or null if parsing failed
*/
private CosemObject getCosemObjectInternal(CosemObjectType cosemObjectType, OBISIdentifier obisIdentifier,
String cosemStringValues) {
private @Nullable CosemObject getCosemObjectInternal(CosemObjectType cosemObjectType, OBISIdentifier obisIdentifier,
String cosemStringValues) {
CosemObject obj = new CosemObject(cosemObjectType, obisIdentifier);

try {
Expand All @@ -147,7 +150,7 @@ private CosemObject getCosemObjectInternal(CosemObjectType cosemObjectType, OBIS
return obj;
} catch (ParseException pe) {
logger.trace("Failed to construct Cosem Object for type {}, values: {}", cosemObjectType, cosemStringValues,
pe);
pe);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import javax.measure.quantity.Power;
import javax.measure.quantity.Volume;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.library.types.QuantityType;
import org.eclipse.smarthome.core.library.unit.MetricPrefix;
import org.eclipse.smarthome.core.library.unit.SIUnits;
Expand All @@ -39,7 +41,8 @@
*
* @param <Q> The {@link Quantity} type of the unit of this class
*/
class CosemQuantity<Q extends Quantity<Q>> extends CosemValueDescriptor<QuantityType<Q>> {
@NonNullByDefault
class CosemQuantity<Q extends @Nullable Quantity<Q>> extends CosemValueDescriptor<QuantityType<Q>> {

public static final Unit<Power> KILO_VAR_UNIT = MetricPrefix.KILO(new BaseUnit<Power>("var"));
public static final Unit<Energy> KILO_VAR_HOUR_UNIT = MetricPrefix.KILO(new BaseUnit<Energy>("varh"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*/
package org.openhab.binding.dsmr.internal.device.cosem;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.library.types.StringType;

/**
Expand All @@ -20,6 +21,7 @@
* @author M. Volaart - Initial contribution
* @author Hilbrand Bouwkamp - Class now a factory instead of data containing class
*/
@NonNullByDefault
class CosemString extends CosemValueDescriptor<StringType> {

public static final CosemString INSTANCE = new CosemString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

import java.text.ParseException;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.smarthome.core.types.State;

/**
* This CosemValueDescriptor provides meta data for a CosemValue
*
* @author M. Volaart - Initial contribution
*/
@NonNullByDefault
abstract class CosemValueDescriptor<S extends State> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

/**
* Class representing an OBISIdentifier
*
* @author M. Volaart - Initial contribution
* @author Hilbrand Bouwkamp - Fix bug in regex pattern.
*/
@NonNullByDefault
public class OBISIdentifier {
/**
* String representing a-b:c.d.e.f OBIS ID
Expand All @@ -36,11 +40,11 @@ public class OBISIdentifier {

/* the six individual group values of the OBIS ID */
private int groupA;
private Integer groupB;
private @Nullable Integer groupB;
private int groupC;
private int groupD;
private Integer groupE;
private Integer groupF;
private @Nullable Integer groupE;
private @Nullable Integer groupF;

/**
* Constructs a new OBIS Identifier (A-B:C.D.E.F)
Expand All @@ -52,7 +56,8 @@ public class OBISIdentifier {
* @param groupE E value
* @param groupF F value
*/
public OBISIdentifier(int groupA, Integer groupB, int groupC, int groupD, Integer groupE, Integer groupF) {
public OBISIdentifier(int groupA, @Nullable Integer groupB, int groupC, int groupD, @Nullable Integer groupE,
@Nullable Integer groupF) {
this.groupA = groupA;
this.groupB = groupB;
this.groupC = groupC;
Expand Down Expand Up @@ -109,7 +114,7 @@ public int getGroupA() {
/**
* @return the groupB
*/
public Integer getGroupB() {
public @Nullable Integer getGroupB() {
return groupB;
}

Expand All @@ -130,14 +135,14 @@ public int getGroupD() {
/**
* @return the groupE
*/
public Integer getGroupE() {
public @Nullable Integer getGroupE() {
return groupE;
}

/**
* @return the groupF
*/
public Integer getGroupF() {
public @Nullable Integer getGroupF() {
return groupF;
}

Expand All @@ -156,7 +161,7 @@ public String toString() {
* @return true if both OBISIdentifiers match, false otherwise
*/
@Override
public boolean equals(Object other) {
public boolean equals(@Nullable Object other) {
OBISIdentifier o;
if (other != null && other instanceof OBISIdentifier) {
o = (OBISIdentifier) other;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package org.openhab.binding.dsmr.internal.device.p1telegram;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* CRC16 implementation.
*
Expand All @@ -22,7 +24,9 @@
*
* @author M. Volaart - Initial contribution
*/
@NonNullByDefault
public class CRC16 {

public enum Polynom {
CRC16_IBM(0xA001), // standard CRC-16 x16+x15+x2+1 (CRC-16-IBM)
CRC16_IBM_REVERSE(0xC002), // standard reverse x16+x14+x+1 (CRC-16-IBM)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
*/
package org.openhab.binding.dsmr.internal.meter;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* This class describes the configuration for a meter.
*
* @author M. Volaart - Initial contribution
* @author Hilbrand Bouwkamp - Added refresh field
*/
@NonNullByDefault
public class DSMRMeterConfiguration {
/**
* M-Bus channel
Expand Down

0 comments on commit 2e7f450

Please sign in to comment.