Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use diamond operator #4001

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void addTemplateAsYAML(String uid, String yaml) throws ParsingException {
try {
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
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);
RuleTemplate entry = RuleTemplateDTOMapper.map(dto);
RuleTemplate template = new RuleTemplate(entry.getUID(), entry.getLabel(), entry.getDescription(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public class ManagedUserLoginConfiguration extends Configuration {
@Override
public AppConfigurationEntry[] getAppConfigurationEntry(String name) {
return new AppConfigurationEntry[] { new AppConfigurationEntry(ManagedUserLoginModule.class.getCanonicalName(),
LoginModuleControlFlag.SUFFICIENT, new HashMap<String, Object>()) };
LoginModuleControlFlag.SUFFICIENT, new HashMap<>()) };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public void visit(ModbusWriteCoilRequestBlueprint blueprint) {
*/
public static ModbusTransaction createTransactionForEndpoint(ModbusSlaveEndpoint endpoint,
ModbusSlaveConnection connection) {
ModbusTransaction transaction = endpoint.accept(new ModbusSlaveEndpointVisitor<ModbusTransaction>() {
ModbusTransaction transaction = endpoint.accept(new ModbusSlaveEndpointVisitor<>() {

@Override
public @NonNull ModbusTransaction visit(ModbusTCPSlaveEndpoint modbusIPSlavePoolingKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ private <R> void invokeCallbackWithError(R request, ModbusFailureCallback<R> cal
try {
logger.trace("Calling error response callback {} for request {}. Error was {} {}", callback, request,
error.getClass().getName(), error.getMessage());
callback.handle(new AsyncModbusFailure<R>(request, error));
callback.handle(new AsyncModbusFailure<>(request, error));
} finally {
logger.trace("Called write response callback {} for request {}. Error was {} {}", callback, request,
error.getClass().getName(), error.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ private long getNumberOfOpenClients(SpyingSocketFactory socketSpy) {
*/
private static class SpyingSocketFactory implements SocketImplFactory {

Queue<SocketImpl> sockets = new ConcurrentLinkedQueue<SocketImpl>();
Queue<SocketImpl> sockets = new ConcurrentLinkedQueue<>();

@Override
public SocketImpl createSocketImpl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ManagedUserBackingEngine(UserRegistry userRegistry) {

@Override
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class SitemapConverters extends DefaultTerminalConverters {
@ValueConverter(rule = "Icon")
public IValueConverter<String> Icon() {

return new IValueConverter<String>() {
return new IValueConverter<>() {

@Override
public String toValue(String string, INode node) throws ValueConverterException {
Expand All @@ -50,7 +50,7 @@ public String toString(String value) throws ValueConverterException {

@ValueConverter(rule = "Command")
public IValueConverter<String> Command() {
return new AbstractNullSafeConverter<String>() {
return new AbstractNullSafeConverter<>() {
@Override
protected String internalToValue(String string, INode node) {
if ((string.startsWith("'") && string.endsWith("'"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,29 +106,29 @@ public SystemProfileFactory(final @Reference ChannelTypeRegistry channelTypeRegi
} else if (RANGE.equals(profileTypeUID)) {
return new SystemRangeStateProfile(callback, context);
} 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,
CommonTriggerEvents.SHORT_PRESSED);
} 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,
CommonTriggerEvents.SHORT_PRESSED);
} 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,
CommonTriggerEvents.SHORT_PRESSED);
} else if (RAWBUTTON_ON_OFF_SWITCH.equals(profileTypeUID)) {
return new RawButtonOnOffSwitchProfile(callback);
} 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,
CommonTriggerEvents.PRESSED);
} 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,
CommonTriggerEvents.PRESSED);
} 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,
CommonTriggerEvents.PRESSED);
} else if (RAWROCKER_DIMMER.equals(profileTypeUID)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class RootUIComponent extends UIComponent implements Identifiable<String> {
String uid;

Set<String> tags = new HashSet<String>();
Set<String> tags = new HashSet<>();

ConfigDescriptionDTO props;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public UIComponent() {
public UIComponent(String componentType) {
super();
this.component = componentType;
this.config = new HashMap<String, Object>();
this.config = new HashMap<>();
}

/**
Expand Down Expand Up @@ -136,9 +136,9 @@ public void setSlots(Map<String, List<UIComponent>> slots) {
*/
public List<UIComponent> addSlot(String slotName) {
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);

return newSlot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public AudioStream get(CachedTTSService tts, String text, Voice voice, AudioForm
fileAndMetadata = lruMediaCacheLocal.get(key, () -> {
try {
AudioStream audioInputStream = tts.synthesizeForCache(text, voice, requestedFormat);
return new LRUMediaCacheEntry<AudioFormatInfo>(key, audioInputStream,
return new LRUMediaCacheEntry<>(key, audioInputStream,
new AudioFormatInfo(audioInputStream.getFormat()));
} catch (TTSException e) {
throw new IllegalStateException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void deactivate() {

@Override
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
@Component
public class StateDescriptionServiceImpl implements StateDescriptionService {

private final Set<StateDescriptionFragmentProvider> stateDescriptionFragmentProviders = Collections.synchronizedSet(
new TreeSet<StateDescriptionFragmentProvider>(new Comparator<StateDescriptionFragmentProvider>() {
private final Set<StateDescriptionFragmentProvider> stateDescriptionFragmentProviders = Collections
.synchronizedSet(new TreeSet<>(new Comparator<>() {
@Override
public int compare(StateDescriptionFragmentProvider provider1,
StateDescriptionFragmentProvider provider2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public final class ImperialUnits extends CustomUnits {
new TransformedUnit<>("gal", CUBIC_INCH, MultiplyConverter.of(231.0)));

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> RADIAN = addUnit(tech.units.indriya.unit.Units.RADIAN);
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)));
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)));
public static final Unit<Density> MICROGRAM_PER_CUBICMETRE = addUnit(new TransformedUnit<>(KILOGRAM_PER_CUBICMETRE,
MultiplyConverter.ofRational(BigInteger.ONE, BigInteger.valueOf(1000000000))));
Expand All @@ -117,8 +117,8 @@ public final class Units extends CustomUnits {
tech.units.indriya.unit.Units.COULOMB.multiply(3600));
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<ElectricConductivity> SIEMENS_PER_METRE = addUnit(new ProductUnit<ElectricConductivity>(
tech.units.indriya.unit.Units.SIEMENS.divide(tech.units.indriya.unit.Units.METRE)));
public static final Unit<ElectricConductivity> SIEMENS_PER_METRE = addUnit(
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<ElectricPotential> VOLT = addUnit(tech.units.indriya.unit.Units.VOLT);
public static final Unit<ElectricResistance> OHM = addUnit(tech.units.indriya.unit.Units.OHM);
Expand Down Expand Up @@ -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> 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<VolumetricFlowRate> LITRE_PER_MINUTE = addUnit(new ProductUnit<VolumetricFlowRate>(
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>(
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>(
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>(
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>(
tech.units.indriya.unit.Units.CUBIC_METRE.divide(tech.units.indriya.unit.Units.DAY)));
public static final Unit<VolumetricFlowRate> LITRE_PER_MINUTE = addUnit(
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<>(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<>(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<>(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<>(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> KILOBIT = addUnit(MetricPrefix.KILO(BIT));
public static final Unit<DataAmount> MEGABIT = addUnit(MetricPrefix.MEGA(BIT));
Expand All @@ -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> PEBIOCTET = addUnit(BinaryPrefix.PEBI(OCTET));
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> MEGABIT_PER_SECOND = addUnit(MetricPrefix.MEGA(BIT_PER_SECOND));
public static final Unit<DataTransferRate> GIGABIT_PER_SECOND = addUnit(MetricPrefix.GIGA(BIT_PER_SECOND));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ public Storage<MetadataSample> getStorage(String name) {
}

private LRUMediaCache<MetadataSample> createCache(long size) throws IOException {
return new LRUMediaCache<MetadataSample>(storageService, size, "lrucachetest.pid",
this.getClass().getClassLoader());
return new LRUMediaCache<>(storageService, size, "lrucachetest.pid", this.getClass().getClassLoader());
}

public static class FakeStream extends InputStream {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public Storage<MetadataSample> getStorage(String name) {
}

private LRUMediaCache<MetadataSample> createCache(long size) throws IOException {
return new LRUMediaCache<MetadataSample>(storageService, size, "lrucachetest.pid",
this.getClass().getClassLoader());
return new LRUMediaCache<>(storageService, size, "lrucachetest.pid", this.getClass().getClassLoader());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,10 @@ public void testAdd(Locale locale) {
assertEquals(ImperialUnits.FAHRENHEIT, result.getUnit());

// test associativity of add
QuantityType<Temperature> tempResult = new QuantityType<Temperature>("1 °F")
.add(new QuantityType<Temperature>("2 °F")).add(new QuantityType<Temperature>("3 °F"));
QuantityType<Temperature> tempResult = new QuantityType<Temperature>("1 °F").add(new QuantityType<>("2 °F"))
.add(new QuantityType<>("3 °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(new QuantityType<>("65 kWh").add(new QuantityType<>("1 kWh")), is(new QuantityType<>("66 kWh")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void assertThatThingsChangeListenerIsNotifiedAboutAddedThing() {
AsyncResultWrapper<Provider<Thing>> thingProviderWrapper = new AsyncResultWrapper<>();
AsyncResultWrapper<Thing> thingWrapper = new AsyncResultWrapper<>();

registerThingsChangeListener(new ProviderChangeListener<Thing>() {
registerThingsChangeListener(new ProviderChangeListener<>() {
@Override
public void added(Provider<Thing> provider, Thing thing) {
thingProviderWrapper.set(provider);
Expand Down Expand Up @@ -150,7 +150,7 @@ public void assertThatThingsChangeListenerIsNotifiedAboutUpdatedThing() {
Thing thing1 = ThingBuilder.create(THING_TYPE_UID, THING1_ID).build();
managedThingProvider.add(thing1);

registerThingsChangeListener(new ProviderChangeListener<Thing>() {
registerThingsChangeListener(new ProviderChangeListener<>() {
@Override
public void added(Provider<Thing> provider, Thing thing) {
}
Expand Down