-
Notifications
You must be signed in to change notification settings - Fork 782
add some nullness annotations #4080
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,23 +25,21 @@ public interface ThingTypeProvider { | |
/** | ||
* Provides a collection of thing types | ||
* | ||
* @param locale | ||
* locale (can be null) | ||
* | ||
* @param locale locale (can be null) | ||
* @return the thing types provided by the {@link ThingTypeProvider} | ||
*/ | ||
Collection<ThingType> getThingTypes(Locale locale); | ||
Collection<ThingType> getThingTypes(@Nullable Locale locale); | ||
|
||
/** | ||
* Provides a thing type for the given UID or null if no type for the | ||
* given UID exists. | ||
* | ||
* @param locale | ||
* locale (can be null) | ||
* @param thingTypeUID the thing type UID | ||
* @param locale locale (can be null) | ||
* @return thing type for the given UID or null if no type for the given | ||
* UID exists | ||
*/ | ||
@Nullable | ||
ThingType getThingType(ThingTypeUID thingTypeUID, Locale locale); | ||
ThingType getThingType(ThingTypeUID thingTypeUID, @Nullable Locale locale); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't we agree on that we only want to state if a parameter is |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
import java.util.List; | ||
import java.util.Locale; | ||
|
||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.eclipse.smarthome.core.i18n.TranslationProvider; | ||
import org.eclipse.smarthome.core.thing.type.BridgeType; | ||
import org.eclipse.smarthome.core.thing.type.ChannelDefinition; | ||
|
@@ -43,7 +44,7 @@ protected void unsetTranslationProvider(TranslationProvider i18nProvider) { | |
this.thingTypeI18nUtil = null; | ||
} | ||
|
||
public ThingType createLocalizedThingType(Bundle bundle, ThingType thingType, Locale locale) { | ||
public ThingType createLocalizedThingType(Bundle bundle, ThingType thingType, @Nullable Locale locale) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't we agree on that we only want to state if a parameter is |
||
final String label = this.thingTypeI18nUtil.getLabel(bundle, thingType.getUID(), thingType.getLabel(), locale); | ||
final String description = this.thingTypeI18nUtil.getDescription(bundle, thingType.getUID(), | ||
thingType.getDescription(), locale); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.eclipse.jdt.annotation.NonNull; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.eclipse.smarthome.core.thing.Bridge; | ||
import org.eclipse.smarthome.core.thing.ThingTypeUID; | ||
|
||
|
@@ -63,9 +65,10 @@ public BridgeType(String bindingId, String thingTypeId, String label) throws Ill | |
* @throws IllegalArgumentException if the UID is null or empty, | ||
* or the the meta information is null | ||
*/ | ||
public BridgeType(ThingTypeUID uid, List<String> supportedBridgeTypeUIDs, String label, String description, | ||
List<ChannelDefinition> channelDefinitions, List<ChannelGroupDefinition> channelGroupDefinitions, | ||
Map<String, String> properties, URI configDescriptionURI) throws IllegalArgumentException { | ||
public BridgeType(@NonNull ThingTypeUID uid, @Nullable List<String> supportedBridgeTypeUIDs, @NonNull String label, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't we agree on that we only want to state if a parameter is |
||
@Nullable String description, @Nullable List<ChannelDefinition> channelDefinitions, | ||
@Nullable List<ChannelGroupDefinition> channelGroupDefinitions, @Nullable Map<String, String> properties, | ||
@Nullable URI configDescriptionURI) throws IllegalArgumentException { | ||
|
||
this(uid, supportedBridgeTypeUIDs, label, description, true, null, channelDefinitions, channelGroupDefinitions, | ||
properties, configDescriptionURI); | ||
|
@@ -100,10 +103,10 @@ public BridgeType(ThingTypeUID uid, List<String> supportedBridgeTypeUIDs, String | |
* @throws IllegalArgumentException if the UID is null or empty, | ||
* or the the meta information is null | ||
*/ | ||
public BridgeType(ThingTypeUID uid, List<String> supportedBridgeTypeUIDs, String label, String description, | ||
boolean listed, List<ChannelDefinition> channelDefinitions, | ||
List<ChannelGroupDefinition> channelGroupDefinitions, Map<String, String> properties, | ||
URI configDescriptionURI) throws IllegalArgumentException { | ||
public BridgeType(@NonNull ThingTypeUID uid, @Nullable List<String> supportedBridgeTypeUIDs, @NonNull String label, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't we agree on that we only want to state if a parameter is |
||
@Nullable String description, boolean listed, @Nullable List<ChannelDefinition> channelDefinitions, | ||
@Nullable List<ChannelGroupDefinition> channelGroupDefinitions, @Nullable Map<String, String> properties, | ||
@Nullable URI configDescriptionURI) throws IllegalArgumentException { | ||
|
||
this(uid, supportedBridgeTypeUIDs, label, description, listed, null, channelDefinitions, | ||
channelGroupDefinitions, properties, configDescriptionURI); | ||
|
@@ -140,10 +143,11 @@ public BridgeType(ThingTypeUID uid, List<String> supportedBridgeTypeUIDs, String | |
* @throws IllegalArgumentException if the UID is null or empty, | ||
* or the the meta information is null | ||
*/ | ||
public BridgeType(ThingTypeUID uid, List<String> supportedBridgeTypeUIDs, String label, String description, | ||
boolean listed, String representationProperty, List<ChannelDefinition> channelDefinitions, | ||
List<ChannelGroupDefinition> channelGroupDefinitions, Map<String, String> properties, | ||
URI configDescriptionURI) throws IllegalArgumentException { | ||
public BridgeType(@NonNull ThingTypeUID uid, @Nullable List<String> supportedBridgeTypeUIDs, @NonNull String label, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't we agree on that we only want to state if a parameter is |
||
@Nullable String description, boolean listed, @Nullable String representationProperty, | ||
@Nullable List<ChannelDefinition> channelDefinitions, | ||
@Nullable List<ChannelGroupDefinition> channelGroupDefinitions, @Nullable Map<String, String> properties, | ||
@Nullable URI configDescriptionURI) throws IllegalArgumentException { | ||
|
||
super(uid, supportedBridgeTypeUIDs, label, description, listed, representationProperty, channelDefinitions, | ||
channelGroupDefinitions, properties, configDescriptionURI); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.eclipse.jdt.annotation.NonNull; | ||
import org.eclipse.jdt.annotation.Nullable; | ||
import org.eclipse.smarthome.core.thing.Channel; | ||
import org.eclipse.smarthome.core.thing.Thing; | ||
|
||
|
@@ -56,16 +58,13 @@ public ChannelDefinition(String id, ChannelTypeUID channelTypeUID) throws Illega | |
* | ||
* @throws IllegalArgumentException if the ID is null or empty, or the type is null | ||
*/ | ||
public ChannelDefinition(String id, ChannelTypeUID channelTypeUID, Map<String, String> properties, String label, | ||
String description) throws IllegalArgumentException { | ||
if ((id == null) || (id.isEmpty())) { | ||
public ChannelDefinition(@NonNull String id, @NonNull ChannelTypeUID channelTypeUID, | ||
@Nullable Map<String, String> properties, @Nullable String label, @Nullable String description) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Didn't we agree on that we only want to state if a parameter is |
||
throws IllegalArgumentException { | ||
if (id.isEmpty()) { | ||
throw new IllegalArgumentException("The ID must neither be null nor empty!"); | ||
} | ||
|
||
if (channelTypeUID == null) { | ||
throw new IllegalArgumentException("The channel type must not be null"); | ||
} | ||
|
||
if (properties != null) { | ||
this.properties = Collections.unmodifiableMap(properties); | ||
} else { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't we agree on that we only want to state if a parameter is
NonNull
and if if can benull
we omit the@Nullable
annotation?