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());
|
final List<Object> lst = new ArrayList<>(collection.size());
|
||||||
for (final Object it : collection) {
|
for (final Object it : collection) {
|
||||||
final Object normalized = normalizeType(it, null);
|
final Object normalized = normalizeType(it, null);
|
||||||
|
if (normalized == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
lst.add(normalized);
|
lst.add(normalized);
|
||||||
if (normalized.getClass() != lst.getFirst().getClass()) {
|
if (normalized.getClass() != lst.getFirst().getClass()) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
|||||||
+8
-12
@@ -49,19 +49,15 @@ final class MinMaxValidator implements ConfigDescriptionParameterValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TypeIntrospection typeIntrospection = TypeIntrospections.get(parameter.getType());
|
TypeIntrospection typeIntrospection = TypeIntrospections.get(parameter.getType());
|
||||||
if (parameter.getMinimum() != null) {
|
BigDecimal min = parameter.getMinimum();
|
||||||
BigDecimal min = parameter.getMinimum();
|
if (min != null && typeIntrospection.isMinViolated(value, min)) {
|
||||||
if (typeIntrospection.isMinViolated(value, min)) {
|
return createMinMaxViolationMessage(parameter.getName(), typeIntrospection.getMinViolationMessageKey(),
|
||||||
return createMinMaxViolationMessage(parameter.getName(), typeIntrospection.getMinViolationMessageKey(),
|
min);
|
||||||
min);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (parameter.getMaximum() != null) {
|
BigDecimal max = parameter.getMaximum();
|
||||||
BigDecimal max = parameter.getMaximum();
|
if (max != null && typeIntrospection.isMaxViolated(value, max)) {
|
||||||
if (typeIntrospection.isMaxViolated(value, max)) {
|
return createMinMaxViolationMessage(parameter.getName(), typeIntrospection.getMaxViolationMessageKey(),
|
||||||
return createMinMaxViolationMessage(parameter.getName(), typeIntrospection.getMaxViolationMessageKey(),
|
max);
|
||||||
max);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -556,7 +556,10 @@ public class GenericItemProvider extends AbstractProvider<Item>
|
|||||||
};
|
};
|
||||||
|
|
||||||
Item baseItem = createItemOfType(baseItemType, modelItem.getName());
|
Item baseItem = createItemOfType(baseItemType, modelItem.getName());
|
||||||
return applyGroupFunction(baseItem, modelItem, function);
|
if (baseItem != null) {
|
||||||
|
return applyGroupFunction(baseItem, modelItem, function);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+10
@@ -437,9 +437,14 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
|
|||||||
final List<ChannelType> allChannelTypes = new ArrayList<>();
|
final List<ChannelType> allChannelTypes = new ArrayList<>();
|
||||||
final Bundle bundle = bundleResolver.resolveBundle(DefaultSystemChannelTypeProvider.class);
|
final Bundle bundle = bundleResolver.resolveBundle(DefaultSystemChannelTypeProvider.class);
|
||||||
|
|
||||||
|
if (bundle == null) {
|
||||||
|
throw new IllegalArgumentException("bundle==null in DefaultSystemChannelTypeProvider::getChannelTypes");
|
||||||
|
}
|
||||||
|
|
||||||
for (final ChannelType channelType : CHANNEL_TYPES) {
|
for (final ChannelType channelType : CHANNEL_TYPES) {
|
||||||
allChannelTypes.add(createLocalizedChannelType(bundle, channelType, locale));
|
allChannelTypes.add(createLocalizedChannelType(bundle, channelType, locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
return allChannelTypes;
|
return allChannelTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,11 +452,16 @@ public class DefaultSystemChannelTypeProvider implements ChannelTypeProvider {
|
|||||||
public @Nullable ChannelType getChannelType(ChannelTypeUID channelTypeUID, @Nullable Locale locale) {
|
public @Nullable ChannelType getChannelType(ChannelTypeUID channelTypeUID, @Nullable Locale locale) {
|
||||||
final Bundle bundle = bundleResolver.resolveBundle(DefaultSystemChannelTypeProvider.class);
|
final Bundle bundle = bundleResolver.resolveBundle(DefaultSystemChannelTypeProvider.class);
|
||||||
|
|
||||||
|
if (bundle == null) {
|
||||||
|
throw new IllegalArgumentException("bundle==null in DefaultSystemChannelTypeProvider::getChannelType");
|
||||||
|
}
|
||||||
|
|
||||||
for (final ChannelType channelType : CHANNEL_TYPES) {
|
for (final ChannelType channelType : CHANNEL_TYPES) {
|
||||||
if (channelTypeUID.equals(channelType.getUID())) {
|
if (channelTypeUID.equals(channelType.getUID())) {
|
||||||
return createLocalizedChannelType(bundle, channelType, locale);
|
return createLocalizedChannelType(bundle, channelType, locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -214,10 +214,8 @@ public class ThingImpl implements Thing {
|
|||||||
throw new IllegalArgumentException("Property name must not be null or empty");
|
throw new IllegalArgumentException("Property name must not be null or empty");
|
||||||
}
|
}
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (value == null) {
|
String val = value;
|
||||||
return properties.remove(name);
|
return val == null ? properties.remove(name) : properties.put(name, val);
|
||||||
}
|
|
||||||
return properties.put(name, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
@@ -81,6 +81,7 @@ public class ChannelStateDescriptionProviderTest {
|
|||||||
|
|
||||||
ChannelType channelType1 = Mockito.mock(ChannelType.class);
|
ChannelType channelType1 = Mockito.mock(ChannelType.class);
|
||||||
|
|
||||||
|
assertNotNull(stateDescription1);
|
||||||
when(channelType1.getState()).thenReturn(stateDescription1);
|
when(channelType1.getState()).thenReturn(stateDescription1);
|
||||||
when(thingTypeRegistry.getChannelType(channel1, Locale.ENGLISH)).thenReturn(channelType1);
|
when(thingTypeRegistry.getChannelType(channel1, Locale.ENGLISH)).thenReturn(channelType1);
|
||||||
when(dynamicStateDescriptionProvider.getStateDescription(channel1, stateDescription1, Locale.ENGLISH))
|
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")
|
.withMaximum(new BigDecimal(100)).withStep(BigDecimal.ONE).withReadOnly(channel2State).withPattern("%s")
|
||||||
.build().toStateDescription();
|
.build().toStateDescription();
|
||||||
ChannelType channelType2 = Mockito.mock(ChannelType.class);
|
ChannelType channelType2 = Mockito.mock(ChannelType.class);
|
||||||
|
assertNotNull(stateDescription2);
|
||||||
|
|
||||||
when(channelType2.getState()).thenReturn(stateDescription2);
|
when(channelType2.getState()).thenReturn(stateDescription2);
|
||||||
when(thingTypeRegistry.getChannelType(channel2, Locale.ENGLISH)).thenReturn(channelType2);
|
when(thingTypeRegistry.getChannelType(channel2, Locale.ENGLISH)).thenReturn(channelType2);
|
||||||
when(dynamicStateDescriptionProvider.getStateDescription(channel2, stateDescription2, Locale.ENGLISH))
|
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")
|
.withMaximum(new BigDecimal(100)).withStep(BigDecimal.ONE).withReadOnly(Boolean.TRUE).withPattern("%s")
|
||||||
.build().toStateDescription();
|
.build().toStateDescription();
|
||||||
ChannelType channelType = Mockito.mock(ChannelType.class);
|
ChannelType channelType = Mockito.mock(ChannelType.class);
|
||||||
|
|
||||||
|
assertNotNull(stateDescription1);
|
||||||
when(channelType.getState()).thenReturn(stateDescription1);
|
when(channelType.getState()).thenReturn(stateDescription1);
|
||||||
when(thingTypeRegistry.getChannelType(channel1, Locale.ENGLISH)).thenReturn(channelType);
|
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")
|
.withMaximum(new BigDecimal(100)).withStep(BigDecimal.ONE).withReadOnly(Boolean.FALSE).withPattern("%s")
|
||||||
.build().toStateDescription();
|
.build().toStateDescription();
|
||||||
ChannelType channelType = Mockito.mock(ChannelType.class);
|
ChannelType channelType = Mockito.mock(ChannelType.class);
|
||||||
|
|
||||||
|
assertNotNull(stateDescription1);
|
||||||
when(channelType.getState()).thenReturn(stateDescription1);
|
when(channelType.getState()).thenReturn(stateDescription1);
|
||||||
when(thingTypeRegistry.getChannelType(channel1, Locale.ENGLISH)).thenReturn(channelType);
|
when(thingTypeRegistry.getChannelType(channel1, Locale.ENGLISH)).thenReturn(channelType);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user