mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Fixes for null pointer error when compiling into eclipse (#5414)
Signed-off-by: Laurent ARNAL <laurent@clae.net>
This commit is contained in:
+4
@@ -263,6 +263,10 @@ public class ConfigUtil {
|
||||
final List<Object> lst = new ArrayList<>(collection.size());
|
||||
for (final Object it : collection) {
|
||||
final Object normalized = normalizeType(it, null);
|
||||
if (normalized == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lst.add(normalized);
|
||||
if (normalized.getClass() != lst.getFirst().getClass()) {
|
||||
throw new IllegalArgumentException(
|
||||
|
||||
+2
-6
@@ -49,20 +49,16 @@ final class MinMaxValidator implements ConfigDescriptionParameterValidator {
|
||||
}
|
||||
|
||||
TypeIntrospection typeIntrospection = TypeIntrospections.get(parameter.getType());
|
||||
if (parameter.getMinimum() != null) {
|
||||
BigDecimal min = parameter.getMinimum();
|
||||
if (typeIntrospection.isMinViolated(value, min)) {
|
||||
if (min != null && typeIntrospection.isMinViolated(value, min)) {
|
||||
return createMinMaxViolationMessage(parameter.getName(), typeIntrospection.getMinViolationMessageKey(),
|
||||
min);
|
||||
}
|
||||
}
|
||||
if (parameter.getMaximum() != null) {
|
||||
BigDecimal max = parameter.getMaximum();
|
||||
if (typeIntrospection.isMaxViolated(value, max)) {
|
||||
if (max != null && typeIntrospection.isMaxViolated(value, max)) {
|
||||
return createMinMaxViolationMessage(parameter.getName(), typeIntrospection.getMaxViolationMessageKey(),
|
||||
max);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -556,8 +556,11 @@ public class GenericItemProvider extends AbstractProvider<Item>
|
||||
};
|
||||
|
||||
Item baseItem = createItemOfType(baseItemType, modelItem.getName());
|
||||
if (baseItem != null) {
|
||||
return applyGroupFunction(baseItem, modelItem, function);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new item of type {@code itemType} by utilizing an appropriate {@link ItemFactory}.
|
||||
|
||||
+10
@@ -437,9 +437,14 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
|
||||
final List<ChannelType> allChannelTypes = new ArrayList<>();
|
||||
final Bundle bundle = bundleResolver.resolveBundle(DefaultSystemChannelTypeProvider.class);
|
||||
|
||||
if (bundle == null) {
|
||||
throw new IllegalArgumentException("bundle==null in DefaultSystemChannelTypeProvider::getChannelTypes");
|
||||
}
|
||||
|
||||
for (final ChannelType channelType : CHANNEL_TYPES) {
|
||||
allChannelTypes.add(createLocalizedChannelType(bundle, channelType, locale));
|
||||
}
|
||||
|
||||
return allChannelTypes;
|
||||
}
|
||||
|
||||
@@ -447,11 +452,16 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
|
||||
public @Nullable ChannelType getChannelType(ChannelTypeUID channelTypeUID, @Nullable Locale locale) {
|
||||
final Bundle bundle = bundleResolver.resolveBundle(DefaultSystemChannelTypeProvider.class);
|
||||
|
||||
if (bundle == null) {
|
||||
throw new IllegalArgumentException("bundle==null in DefaultSystemChannelTypeProvider::getChannelType");
|
||||
}
|
||||
|
||||
for (final ChannelType channelType : CHANNEL_TYPES) {
|
||||
if (channelTypeUID.equals(channelType.getUID())) {
|
||||
return createLocalizedChannelType(bundle, channelType, locale);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -214,10 +214,8 @@ public class ThingImpl implements Thing {
|
||||
throw new IllegalArgumentException("Property name must not be null or empty");
|
||||
}
|
||||
synchronized (this) {
|
||||
if (value == null) {
|
||||
return properties.remove(name);
|
||||
}
|
||||
return properties.put(name, value);
|
||||
String val = value;
|
||||
return val == null ? properties.remove(name) : properties.put(name, val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -81,6 +81,7 @@ public class ChannelStateDescriptionProviderTest {
|
||||
|
||||
ChannelType channelType1 = Mockito.mock(ChannelType.class);
|
||||
|
||||
assertNotNull(stateDescription1);
|
||||
when(channelType1.getState()).thenReturn(stateDescription1);
|
||||
when(thingTypeRegistry.getChannelType(channel1, Locale.ENGLISH)).thenReturn(channelType1);
|
||||
when(dynamicStateDescriptionProvider.getStateDescription(channel1, stateDescription1, Locale.ENGLISH))
|
||||
@@ -93,6 +94,8 @@ public class ChannelStateDescriptionProviderTest {
|
||||
.withMaximum(new BigDecimal(100)).withStep(BigDecimal.ONE).withReadOnly(channel2State).withPattern("%s")
|
||||
.build().toStateDescription();
|
||||
ChannelType channelType2 = Mockito.mock(ChannelType.class);
|
||||
assertNotNull(stateDescription2);
|
||||
|
||||
when(channelType2.getState()).thenReturn(stateDescription2);
|
||||
when(thingTypeRegistry.getChannelType(channel2, Locale.ENGLISH)).thenReturn(channelType2);
|
||||
when(dynamicStateDescriptionProvider.getStateDescription(channel2, stateDescription2, Locale.ENGLISH))
|
||||
@@ -117,6 +120,8 @@ public class ChannelStateDescriptionProviderTest {
|
||||
.withMaximum(new BigDecimal(100)).withStep(BigDecimal.ONE).withReadOnly(Boolean.TRUE).withPattern("%s")
|
||||
.build().toStateDescription();
|
||||
ChannelType channelType = Mockito.mock(ChannelType.class);
|
||||
|
||||
assertNotNull(stateDescription1);
|
||||
when(channelType.getState()).thenReturn(stateDescription1);
|
||||
when(thingTypeRegistry.getChannelType(channel1, Locale.ENGLISH)).thenReturn(channelType);
|
||||
|
||||
@@ -142,6 +147,8 @@ public class ChannelStateDescriptionProviderTest {
|
||||
.withMaximum(new BigDecimal(100)).withStep(BigDecimal.ONE).withReadOnly(Boolean.FALSE).withPattern("%s")
|
||||
.build().toStateDescription();
|
||||
ChannelType channelType = Mockito.mock(ChannelType.class);
|
||||
|
||||
assertNotNull(stateDescription1);
|
||||
when(channelType.getState()).thenReturn(stateDescription1);
|
||||
when(thingTypeRegistry.getChannelType(channel1, Locale.ENGLISH)).thenReturn(channelType);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user