Use diamond operator (#4001)

Often the type can be inferred so the diamond operator can be used to simplify the code.

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2024-01-03 08:22:43 +01:00
committed by GitHub
parent dc5f50db63
commit 58a106d36d
19 changed files with 45 additions and 47 deletions
@@ -137,7 +137,7 @@ public class MarketplaceRuleTemplateProvider extends AbstractManagedProvider<Rul
try { try {
RuleTemplateDTO dto = yamlMapper.readValue(yaml, RuleTemplateDTO.class); RuleTemplateDTO dto = yamlMapper.readValue(yaml, RuleTemplateDTO.class);
// add a tag with the add-on ID to be able to identify the widget in the registry // add a tag with the add-on ID to be able to identify the widget in the registry
dto.tags = new HashSet<@Nullable String>((dto.tags != null) ? dto.tags : new HashSet<String>()); dto.tags = new HashSet<@Nullable String>((dto.tags != null) ? dto.tags : new HashSet<>());
dto.tags.add(uid); dto.tags.add(uid);
RuleTemplate entry = RuleTemplateDTOMapper.map(dto); RuleTemplate entry = RuleTemplateDTOMapper.map(dto);
RuleTemplate template = new RuleTemplate(entry.getUID(), entry.getLabel(), entry.getDescription(), RuleTemplate template = new RuleTemplate(entry.getUID(), entry.getLabel(), entry.getDescription(),
@@ -28,6 +28,6 @@ public class ManagedUserLoginConfiguration extends Configuration {
@Override @Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) { public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
return new AppConfigurationEntry[] { new AppConfigurationEntry(ManagedUserLoginModule.class.getCanonicalName(), return new AppConfigurationEntry[] { new AppConfigurationEntry(ManagedUserLoginModule.class.getCanonicalName(),
LoginModuleControlFlag.SUFFICIENT, new HashMap<String, Object>()) }; LoginModuleControlFlag.SUFFICIENT, new HashMap<>()) };
} }
} }
@@ -190,7 +190,7 @@ public class ModbusLibraryWrapper {
*/ */
public static ModbusTransaction createTransactionForEndpoint(ModbusSlaveEndpoint endpoint, public static ModbusTransaction createTransactionForEndpoint(ModbusSlaveEndpoint endpoint,
ModbusSlaveConnection connection) { ModbusSlaveConnection connection) {
ModbusTransaction transaction = endpoint.accept(new ModbusSlaveEndpointVisitor<ModbusTransaction>() { ModbusTransaction transaction = endpoint.accept(new ModbusSlaveEndpointVisitor<>() {
@Override @Override
public @NonNull ModbusTransaction visit(ModbusTCPSlaveEndpoint modbusIPSlavePoolingKey) { public @NonNull ModbusTransaction visit(ModbusTCPSlaveEndpoint modbusIPSlavePoolingKey) {
@@ -488,7 +488,7 @@ public class ModbusManagerImpl implements ModbusManager {
try { try {
logger.trace("Calling error response callback {} for request {}. Error was {} {}", callback, request, logger.trace("Calling error response callback {} for request {}. Error was {} {}", callback, request,
error.getClass().getName(), error.getMessage()); error.getClass().getName(), error.getMessage());
callback.handle(new AsyncModbusFailure<R>(request, error)); callback.handle(new AsyncModbusFailure<>(request, error));
} finally { } finally {
logger.trace("Called write response callback {} for request {}. Error was {} {}", callback, request, logger.trace("Called write response callback {} for request {}. Error was {} {}", callback, request,
error.getClass().getName(), error.getMessage()); error.getClass().getName(), error.getMessage());
@@ -952,7 +952,7 @@ public class SmokeTest extends IntegrationTestSupport {
*/ */
private static class SpyingSocketFactory implements SocketImplFactory { private static class SpyingSocketFactory implements SocketImplFactory {
Queue<SocketImpl> sockets = new ConcurrentLinkedQueue<SocketImpl>(); Queue<SocketImpl> sockets = new ConcurrentLinkedQueue<>();
@Override @Override
public SocketImpl createSocketImpl() { public SocketImpl createSocketImpl() {
@@ -42,7 +42,7 @@ public class ManagedUserBackingEngine implements BackingEngine {
@Override @Override
public void addUser(String username, String password) { public void addUser(String username, String password) {
userRegistry.register(username, password, new HashSet<String>(Set.of(Role.USER))); userRegistry.register(username, password, new HashSet<>(Set.of(Role.USER)));
} }
@Override @Override
@@ -28,7 +28,7 @@ public class SitemapConverters extends DefaultTerminalConverters {
@ValueConverter(rule = "Icon") @ValueConverter(rule = "Icon")
public IValueConverter<String> Icon() { public IValueConverter<String> Icon() {
return new IValueConverter<String>() { return new IValueConverter<>() {
@Override @Override
public String toValue(String string, INode node) throws ValueConverterException { public String toValue(String string, INode node) throws ValueConverterException {
@@ -50,7 +50,7 @@ public class SitemapConverters extends DefaultTerminalConverters {
@ValueConverter(rule = "Command") @ValueConverter(rule = "Command")
public IValueConverter<String> Command() { public IValueConverter<String> Command() {
return new AbstractNullSafeConverter<String>() { return new AbstractNullSafeConverter<>() {
@Override @Override
protected String internalToValue(String string, INode node) { protected String internalToValue(String string, INode node) {
if ((string.startsWith("'") && string.endsWith("'")) if ((string.startsWith("'") && string.endsWith("'"))
@@ -106,29 +106,29 @@ public class SystemProfileFactory implements ProfileFactory, ProfileAdvisor, Pro
} else if (RANGE.equals(profileTypeUID)) { } else if (RANGE.equals(profileTypeUID)) {
return new SystemRangeStateProfile(callback, context); return new SystemRangeStateProfile(callback, context);
} else if (BUTTON_TOGGLE_SWITCH.equals(profileTypeUID)) { } else if (BUTTON_TOGGLE_SWITCH.equals(profileTypeUID)) {
return new ToggleProfile<OnOffType>(callback, context, BUTTON_TOGGLE_SWITCH, return new ToggleProfile<>(callback, context, BUTTON_TOGGLE_SWITCH,
DefaultSystemChannelTypeProvider.SYSTEM_BUTTON, OnOffType.ON, OnOffType.OFF, DefaultSystemChannelTypeProvider.SYSTEM_BUTTON, OnOffType.ON, OnOffType.OFF,
CommonTriggerEvents.SHORT_PRESSED); CommonTriggerEvents.SHORT_PRESSED);
} else if (BUTTON_TOGGLE_PLAYER.equals(profileTypeUID)) { } else if (BUTTON_TOGGLE_PLAYER.equals(profileTypeUID)) {
return new ToggleProfile<PlayPauseType>(callback, context, BUTTON_TOGGLE_PLAYER, return new ToggleProfile<>(callback, context, BUTTON_TOGGLE_PLAYER,
DefaultSystemChannelTypeProvider.SYSTEM_BUTTON, PlayPauseType.PLAY, PlayPauseType.PAUSE, DefaultSystemChannelTypeProvider.SYSTEM_BUTTON, PlayPauseType.PLAY, PlayPauseType.PAUSE,
CommonTriggerEvents.SHORT_PRESSED); CommonTriggerEvents.SHORT_PRESSED);
} else if (BUTTON_TOGGLE_ROLLERSHUTTER.equals(profileTypeUID)) { } else if (BUTTON_TOGGLE_ROLLERSHUTTER.equals(profileTypeUID)) {
return new ToggleProfile<UpDownType>(callback, context, BUTTON_TOGGLE_ROLLERSHUTTER, return new ToggleProfile<>(callback, context, BUTTON_TOGGLE_ROLLERSHUTTER,
DefaultSystemChannelTypeProvider.SYSTEM_BUTTON, UpDownType.UP, UpDownType.DOWN, DefaultSystemChannelTypeProvider.SYSTEM_BUTTON, UpDownType.UP, UpDownType.DOWN,
CommonTriggerEvents.SHORT_PRESSED); CommonTriggerEvents.SHORT_PRESSED);
} else if (RAWBUTTON_ON_OFF_SWITCH.equals(profileTypeUID)) { } else if (RAWBUTTON_ON_OFF_SWITCH.equals(profileTypeUID)) {
return new RawButtonOnOffSwitchProfile(callback); return new RawButtonOnOffSwitchProfile(callback);
} else if (RAWBUTTON_TOGGLE_SWITCH.equals(profileTypeUID)) { } else if (RAWBUTTON_TOGGLE_SWITCH.equals(profileTypeUID)) {
return new ToggleProfile<OnOffType>(callback, context, RAWBUTTON_TOGGLE_SWITCH, return new ToggleProfile<>(callback, context, RAWBUTTON_TOGGLE_SWITCH,
DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON, OnOffType.ON, OnOffType.OFF, DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON, OnOffType.ON, OnOffType.OFF,
CommonTriggerEvents.PRESSED); CommonTriggerEvents.PRESSED);
} else if (RAWBUTTON_TOGGLE_PLAYER.equals(profileTypeUID)) { } else if (RAWBUTTON_TOGGLE_PLAYER.equals(profileTypeUID)) {
return new ToggleProfile<PlayPauseType>(callback, context, RAWBUTTON_TOGGLE_PLAYER, return new ToggleProfile<>(callback, context, RAWBUTTON_TOGGLE_PLAYER,
DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON, PlayPauseType.PLAY, PlayPauseType.PAUSE, DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON, PlayPauseType.PLAY, PlayPauseType.PAUSE,
CommonTriggerEvents.PRESSED); CommonTriggerEvents.PRESSED);
} else if (RAWBUTTON_TOGGLE_ROLLERSHUTTER.equals(profileTypeUID)) { } else if (RAWBUTTON_TOGGLE_ROLLERSHUTTER.equals(profileTypeUID)) {
return new ToggleProfile<UpDownType>(callback, context, RAWBUTTON_TOGGLE_ROLLERSHUTTER, return new ToggleProfile<>(callback, context, RAWBUTTON_TOGGLE_ROLLERSHUTTER,
DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON, UpDownType.UP, UpDownType.DOWN, DefaultSystemChannelTypeProvider.SYSTEM_RAWBUTTON, UpDownType.UP, UpDownType.DOWN,
CommonTriggerEvents.PRESSED); CommonTriggerEvents.PRESSED);
} else if (RAWROCKER_DIMMER.equals(profileTypeUID)) { } else if (RAWROCKER_DIMMER.equals(profileTypeUID)) {
@@ -36,7 +36,7 @@ import org.openhab.core.config.core.dto.ConfigDescriptionDTO;
public class RootUIComponent extends UIComponent implements Identifiable<String> { public class RootUIComponent extends UIComponent implements Identifiable<String> {
String uid; String uid;
Set<String> tags = new HashSet<String>(); Set<String> tags = new HashSet<>();
ConfigDescriptionDTO props; ConfigDescriptionDTO props;
@@ -52,7 +52,7 @@ public class UIComponent {
public UIComponent(String componentType) { public UIComponent(String componentType) {
super(); super();
this.component = componentType; this.component = componentType;
this.config = new HashMap<String, Object>(); this.config = new HashMap<>();
} }
/** /**
@@ -136,9 +136,9 @@ public class UIComponent {
*/ */
public List<UIComponent> addSlot(String slotName) { public List<UIComponent> addSlot(String slotName) {
if (slots == null) { if (slots == null) {
slots = new HashMap<String, List<UIComponent>>(); slots = new HashMap<>();
} }
List<UIComponent> newSlot = new ArrayList<UIComponent>(); List<UIComponent> newSlot = new ArrayList<>();
this.slots.put(slotName, newSlot); this.slots.put(slotName, newSlot);
return newSlot; return newSlot;
@@ -122,7 +122,7 @@ public class TTSLRUCacheImpl implements TTSCache {
fileAndMetadata = lruMediaCacheLocal.get(key, () -> { fileAndMetadata = lruMediaCacheLocal.get(key, () -> {
try { try {
AudioStream audioInputStream = tts.synthesizeForCache(text, voice, requestedFormat); AudioStream audioInputStream = tts.synthesizeForCache(text, voice, requestedFormat);
return new LRUMediaCacheEntry<AudioFormatInfo>(key, audioInputStream, return new LRUMediaCacheEntry<>(key, audioInputStream,
new AudioFormatInfo(audioInputStream.getFormat())); new AudioFormatInfo(audioInputStream.getFormat()));
} catch (TTSException e) { } catch (TTSException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
@@ -63,7 +63,7 @@ public class SafeCallerImpl implements SafeCaller {
@Override @Override
public <T> SafeCallerBuilder<T> create(T target, Class<T> interfaceType) { public <T> SafeCallerBuilder<T> create(T target, Class<T> interfaceType) {
return new SafeCallerBuilderImpl<T>(target, new Class<?>[] { interfaceType }, manager); return new SafeCallerBuilderImpl<>(target, new Class<?>[] { interfaceType }, manager);
} }
protected ExecutorService getScheduler() { protected ExecutorService getScheduler() {
@@ -40,8 +40,8 @@ import org.osgi.service.component.annotations.ReferencePolicy;
@Component @Component
public class StateDescriptionServiceImpl implements StateDescriptionService { public class StateDescriptionServiceImpl implements StateDescriptionService {
private final Set<StateDescriptionFragmentProvider> stateDescriptionFragmentProviders = Collections.synchronizedSet( private final Set<StateDescriptionFragmentProvider> stateDescriptionFragmentProviders = Collections
new TreeSet<StateDescriptionFragmentProvider>(new Comparator<StateDescriptionFragmentProvider>() { .synchronizedSet(new TreeSet<>(new Comparator<>() {
@Override @Override
public int compare(StateDescriptionFragmentProvider provider1, public int compare(StateDescriptionFragmentProvider provider1,
StateDescriptionFragmentProvider provider2) { StateDescriptionFragmentProvider provider2) {
@@ -92,7 +92,7 @@ public final class ImperialUnits extends CustomUnits {
new TransformedUnit<>("gal", CUBIC_INCH, MultiplyConverter.of(231.0))); new TransformedUnit<>("gal", CUBIC_INCH, MultiplyConverter.of(231.0)));
public static final Unit<VolumetricFlowRate> GALLON_PER_MINUTE = addUnit( public static final Unit<VolumetricFlowRate> GALLON_PER_MINUTE = addUnit(
new ProductUnit<VolumetricFlowRate>(GALLON_LIQUID_US.divide(tech.units.indriya.unit.Units.MINUTE))); new ProductUnit<>(GALLON_LIQUID_US.divide(tech.units.indriya.unit.Units.MINUTE)));
/** /**
* Add unit symbols for imperial units. * Add unit symbols for imperial units.
@@ -95,10 +95,10 @@ public final class Units extends CustomUnits {
public static final Unit<Angle> DEGREE_ANGLE = addUnit(NonSI.DEGREE_ANGLE); public static final Unit<Angle> DEGREE_ANGLE = addUnit(NonSI.DEGREE_ANGLE);
public static final Unit<Angle> RADIAN = addUnit(tech.units.indriya.unit.Units.RADIAN); public static final Unit<Angle> RADIAN = addUnit(tech.units.indriya.unit.Units.RADIAN);
public static final Unit<ArealDensity> DOBSON_UNIT = addUnit( public static final Unit<ArealDensity> DOBSON_UNIT = addUnit(
new ProductUnit<ArealDensity>(MetricPrefix.MILLI(tech.units.indriya.unit.Units.MOLE).multiply(0.4462) new ProductUnit<>(MetricPrefix.MILLI(tech.units.indriya.unit.Units.MOLE).multiply(0.4462)
.divide(tech.units.indriya.unit.Units.SQUARE_METRE))); .divide(tech.units.indriya.unit.Units.SQUARE_METRE)));
public static final Unit<CatalyticActivity> KATAL = addUnit(tech.units.indriya.unit.Units.KATAL); public static final Unit<CatalyticActivity> KATAL = addUnit(tech.units.indriya.unit.Units.KATAL);
public static final Unit<Density> KILOGRAM_PER_CUBICMETRE = addUnit(new ProductUnit<Density>( public static final Unit<Density> KILOGRAM_PER_CUBICMETRE = addUnit(new ProductUnit<>(
tech.units.indriya.unit.Units.KILOGRAM.divide(tech.units.indriya.unit.Units.CUBIC_METRE))); tech.units.indriya.unit.Units.KILOGRAM.divide(tech.units.indriya.unit.Units.CUBIC_METRE)));
public static final Unit<Density> MICROGRAM_PER_CUBICMETRE = addUnit(new TransformedUnit<>(KILOGRAM_PER_CUBICMETRE, public static final Unit<Density> MICROGRAM_PER_CUBICMETRE = addUnit(new TransformedUnit<>(KILOGRAM_PER_CUBICMETRE,
MultiplyConverter.ofRational(BigInteger.ONE, BigInteger.valueOf(1000000000)))); MultiplyConverter.ofRational(BigInteger.ONE, BigInteger.valueOf(1000000000))));
@@ -117,8 +117,8 @@ public final class Units extends CustomUnits {
tech.units.indriya.unit.Units.COULOMB.multiply(3600)); tech.units.indriya.unit.Units.COULOMB.multiply(3600));
public static final Unit<ElectricCharge> MILLIAMPERE_HOUR = addUnit(MetricPrefix.MILLI(AMPERE_HOUR)); public static final Unit<ElectricCharge> MILLIAMPERE_HOUR = addUnit(MetricPrefix.MILLI(AMPERE_HOUR));
public static final Unit<ElectricConductance> SIEMENS = addUnit(tech.units.indriya.unit.Units.SIEMENS); public static final Unit<ElectricConductance> SIEMENS = addUnit(tech.units.indriya.unit.Units.SIEMENS);
public static final Unit<ElectricConductivity> SIEMENS_PER_METRE = addUnit(new ProductUnit<ElectricConductivity>( public static final Unit<ElectricConductivity> SIEMENS_PER_METRE = addUnit(
tech.units.indriya.unit.Units.SIEMENS.divide(tech.units.indriya.unit.Units.METRE))); new ProductUnit<>(tech.units.indriya.unit.Units.SIEMENS.divide(tech.units.indriya.unit.Units.METRE)));
public static final Unit<ElectricInductance> HENRY = addUnit(tech.units.indriya.unit.Units.HENRY); public static final Unit<ElectricInductance> HENRY = addUnit(tech.units.indriya.unit.Units.HENRY);
public static final Unit<ElectricPotential> VOLT = addUnit(tech.units.indriya.unit.Units.VOLT); public static final Unit<ElectricPotential> VOLT = addUnit(tech.units.indriya.unit.Units.VOLT);
public static final Unit<ElectricResistance> OHM = addUnit(tech.units.indriya.unit.Units.OHM); public static final Unit<ElectricResistance> OHM = addUnit(tech.units.indriya.unit.Units.OHM);
@@ -193,16 +193,16 @@ public final class Units extends CustomUnits {
public static final Unit<Time> WEEK = addUnit(tech.units.indriya.unit.Units.WEEK); public static final Unit<Time> WEEK = addUnit(tech.units.indriya.unit.Units.WEEK);
public static final Unit<Time> MONTH = addUnit(tech.units.indriya.unit.Units.MONTH); public static final Unit<Time> MONTH = addUnit(tech.units.indriya.unit.Units.MONTH);
public static final Unit<Time> YEAR = addUnit(tech.units.indriya.unit.Units.YEAR); public static final Unit<Time> YEAR = addUnit(tech.units.indriya.unit.Units.YEAR);
public static final Unit<VolumetricFlowRate> LITRE_PER_MINUTE = addUnit(new ProductUnit<VolumetricFlowRate>( public static final Unit<VolumetricFlowRate> LITRE_PER_MINUTE = addUnit(
tech.units.indriya.unit.Units.LITRE.divide(tech.units.indriya.unit.Units.MINUTE))); new ProductUnit<>(tech.units.indriya.unit.Units.LITRE.divide(tech.units.indriya.unit.Units.MINUTE)));
public static final Unit<VolumetricFlowRate> CUBICMETRE_PER_SECOND = addUnit(new ProductUnit<VolumetricFlowRate>( public static final Unit<VolumetricFlowRate> CUBICMETRE_PER_SECOND = addUnit(
tech.units.indriya.unit.Units.CUBIC_METRE.divide(tech.units.indriya.unit.Units.SECOND))); new ProductUnit<>(tech.units.indriya.unit.Units.CUBIC_METRE.divide(tech.units.indriya.unit.Units.SECOND)));
public static final Unit<VolumetricFlowRate> CUBICMETRE_PER_MINUTE = addUnit(new ProductUnit<VolumetricFlowRate>( public static final Unit<VolumetricFlowRate> CUBICMETRE_PER_MINUTE = addUnit(
tech.units.indriya.unit.Units.CUBIC_METRE.divide(tech.units.indriya.unit.Units.MINUTE))); new ProductUnit<>(tech.units.indriya.unit.Units.CUBIC_METRE.divide(tech.units.indriya.unit.Units.MINUTE)));
public static final Unit<VolumetricFlowRate> CUBICMETRE_PER_HOUR = addUnit(new ProductUnit<VolumetricFlowRate>( public static final Unit<VolumetricFlowRate> CUBICMETRE_PER_HOUR = addUnit(
tech.units.indriya.unit.Units.CUBIC_METRE.divide(tech.units.indriya.unit.Units.HOUR))); new ProductUnit<>(tech.units.indriya.unit.Units.CUBIC_METRE.divide(tech.units.indriya.unit.Units.HOUR)));
public static final Unit<VolumetricFlowRate> CUBICMETRE_PER_DAY = addUnit(new ProductUnit<VolumetricFlowRate>( public static final Unit<VolumetricFlowRate> CUBICMETRE_PER_DAY = addUnit(
tech.units.indriya.unit.Units.CUBIC_METRE.divide(tech.units.indriya.unit.Units.DAY))); new ProductUnit<>(tech.units.indriya.unit.Units.CUBIC_METRE.divide(tech.units.indriya.unit.Units.DAY)));
public static final Unit<DataAmount> BIT = addUnit(new BaseUnit<>("bit", UnitDimension.parse('X'))); public static final Unit<DataAmount> BIT = addUnit(new BaseUnit<>("bit", UnitDimension.parse('X')));
public static final Unit<DataAmount> KILOBIT = addUnit(MetricPrefix.KILO(BIT)); public static final Unit<DataAmount> KILOBIT = addUnit(MetricPrefix.KILO(BIT));
public static final Unit<DataAmount> MEGABIT = addUnit(MetricPrefix.MEGA(BIT)); public static final Unit<DataAmount> MEGABIT = addUnit(MetricPrefix.MEGA(BIT));
@@ -227,7 +227,7 @@ public final class Units extends CustomUnits {
public static final Unit<DataAmount> TEBIOCTET = addUnit(BinaryPrefix.TEBI(OCTET)); public static final Unit<DataAmount> TEBIOCTET = addUnit(BinaryPrefix.TEBI(OCTET));
public static final Unit<DataAmount> PEBIOCTET = addUnit(BinaryPrefix.PEBI(OCTET)); public static final Unit<DataAmount> PEBIOCTET = addUnit(BinaryPrefix.PEBI(OCTET));
public static final Unit<DataTransferRate> BIT_PER_SECOND = addUnit( public static final Unit<DataTransferRate> BIT_PER_SECOND = addUnit(
new ProductUnit<DataTransferRate>(BIT.divide(tech.units.indriya.unit.Units.SECOND))); new ProductUnit<>(BIT.divide(tech.units.indriya.unit.Units.SECOND)));
public static final Unit<DataTransferRate> KILOBIT_PER_SECOND = addUnit(MetricPrefix.KILO(BIT_PER_SECOND)); public static final Unit<DataTransferRate> KILOBIT_PER_SECOND = addUnit(MetricPrefix.KILO(BIT_PER_SECOND));
public static final Unit<DataTransferRate> MEGABIT_PER_SECOND = addUnit(MetricPrefix.MEGA(BIT_PER_SECOND)); public static final Unit<DataTransferRate> MEGABIT_PER_SECOND = addUnit(MetricPrefix.MEGA(BIT_PER_SECOND));
public static final Unit<DataTransferRate> GIGABIT_PER_SECOND = addUnit(MetricPrefix.GIGA(BIT_PER_SECOND)); public static final Unit<DataTransferRate> GIGABIT_PER_SECOND = addUnit(MetricPrefix.GIGA(BIT_PER_SECOND));
@@ -74,8 +74,7 @@ public class LRUMediaCacheEntryTest {
} }
private LRUMediaCache<MetadataSample> createCache(long size) throws IOException { private LRUMediaCache<MetadataSample> createCache(long size) throws IOException {
return new LRUMediaCache<MetadataSample>(storageService, size, "lrucachetest.pid", return new LRUMediaCache<>(storageService, size, "lrucachetest.pid", this.getClass().getClassLoader());
this.getClass().getClassLoader());
} }
public static class FakeStream extends InputStream { public static class FakeStream extends InputStream {
@@ -75,8 +75,7 @@ public class LRUMediaCacheTest {
} }
private LRUMediaCache<MetadataSample> createCache(long size) throws IOException { private LRUMediaCache<MetadataSample> createCache(long size) throws IOException {
return new LRUMediaCache<MetadataSample>(storageService, size, "lrucachetest.pid", return new LRUMediaCache<>(storageService, size, "lrucachetest.pid", this.getClass().getClassLoader());
this.getClass().getClassLoader());
} }
/** /**
@@ -375,10 +375,10 @@ public class QuantityTypeTest {
assertEquals(ImperialUnits.FAHRENHEIT, result.getUnit()); assertEquals(ImperialUnits.FAHRENHEIT, result.getUnit());
// test associativity of add // test associativity of add
QuantityType<Temperature> tempResult = new QuantityType<Temperature>("1 °F") QuantityType<Temperature> tempResult = new QuantityType<Temperature>("1 °F").add(new QuantityType<>("2 °F"))
.add(new QuantityType<Temperature>("2 °F")).add(new QuantityType<Temperature>("3 °F")); .add(new QuantityType<>("3 °F"));
assertThat(tempResult, is(new QuantityType<Temperature>("1 °F") assertThat(tempResult, is(new QuantityType<Temperature>("1 °F")
.add(new QuantityType<Temperature>("2 °F").add(new QuantityType<Temperature>("3 °F"))))); .add(new QuantityType<Temperature>("2 °F").add(new QuantityType<>("3 °F")))));
assertThat(tempResult, is(new QuantityType<Temperature>("6 °F"))); assertThat(tempResult, is(new QuantityType<Temperature>("6 °F")));
assertThat(new QuantityType<>("65 kWh").add(new QuantityType<>("1 kWh")), is(new QuantityType<>("66 kWh"))); assertThat(new QuantityType<>("65 kWh").add(new QuantityType<>("1 kWh")), is(new QuantityType<>("66 kWh")));
@@ -115,7 +115,7 @@ public class ManagedThingProviderOSGiTest extends JavaOSGiTest {
AsyncResultWrapper<Provider<Thing>> thingProviderWrapper = new AsyncResultWrapper<>(); AsyncResultWrapper<Provider<Thing>> thingProviderWrapper = new AsyncResultWrapper<>();
AsyncResultWrapper<Thing> thingWrapper = new AsyncResultWrapper<>(); AsyncResultWrapper<Thing> thingWrapper = new AsyncResultWrapper<>();
registerThingsChangeListener(new ProviderChangeListener<Thing>() { registerThingsChangeListener(new ProviderChangeListener<>() {
@Override @Override
public void added(Provider<Thing> provider, Thing thing) { public void added(Provider<Thing> provider, Thing thing) {
thingProviderWrapper.set(provider); thingProviderWrapper.set(provider);
@@ -150,7 +150,7 @@ public class ManagedThingProviderOSGiTest extends JavaOSGiTest {
Thing thing1 = ThingBuilder.create(THING_TYPE_UID, THING1_ID).build(); Thing thing1 = ThingBuilder.create(THING_TYPE_UID, THING1_ID).build();
managedThingProvider.add(thing1); managedThingProvider.add(thing1);
registerThingsChangeListener(new ProviderChangeListener<Thing>() { registerThingsChangeListener(new ProviderChangeListener<>() {
@Override @Override
public void added(Provider<Thing> provider, Thing thing) { public void added(Provider<Thing> provider, Thing thing) {
} }