Cleanup Java code (#2263)
This cleanup includes: * Fix deprecations * Fix JavaDocs * Remove redundant toString calls * Remove redundant semicolons * Simplify boolean expressions * Use diamond operator * Use enhanced for loops * Use instanceof pattern matching * Use isEmpty instead of 0 comparisons * Use lambdas * Use static inner classes * Use StandardCharsets Also adds the SA_LOCAL_SELF_COMPARISON suppression similar as used in other repositories for https://github.com/spotbugs/spotbugs/issues/1992. Signed-off-by: Wouter Born <github@maindrain.net>pull/2278/head
parent
f912de509c
commit
ef523642a9
|
@ -13,7 +13,6 @@
|
|||
package org.openhab.ui.basic.internal.render;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
@ -35,6 +34,7 @@ import org.openhab.core.library.types.QuantityType;
|
|||
import org.openhab.core.model.sitemap.sitemap.Widget;
|
||||
import org.openhab.core.types.State;
|
||||
import org.openhab.core.ui.items.ItemUIRegistry;
|
||||
import org.openhab.core.util.ColorUtil;
|
||||
import org.openhab.ui.basic.internal.WebAppConfig;
|
||||
import org.openhab.ui.basic.render.RenderException;
|
||||
import org.openhab.ui.basic.render.WidgetRenderer;
|
||||
|
@ -106,7 +106,7 @@ public abstract class AbstractWidgetRenderer implements WidgetRenderer {
|
|||
/**
|
||||
* Replace some common values in the widget template
|
||||
*
|
||||
* @param snippet snippet HTML code
|
||||
* @param originalSnippet snippet HTML code
|
||||
* @param w corresponding widget
|
||||
* @return HTML code
|
||||
*/
|
||||
|
@ -117,7 +117,7 @@ public abstract class AbstractWidgetRenderer implements WidgetRenderer {
|
|||
/**
|
||||
* Replace some common values in the widget template
|
||||
*
|
||||
* @param snippet snippet HTML code
|
||||
* @param originalSnippet snippet HTML code
|
||||
* @param w corresponding widget
|
||||
* @param ignoreStateForIcon true if state has to be ignored when requesting the icon
|
||||
* @return HTML code
|
||||
|
@ -338,12 +338,7 @@ public abstract class AbstractWidgetRenderer implements WidgetRenderer {
|
|||
return "";
|
||||
}
|
||||
|
||||
try {
|
||||
return URLEncoder.encode(string, "UTF-8");
|
||||
} catch (UnsupportedEncodingException use) {
|
||||
logger.warn("Cannot escape string '{}'. Returning unmodified string.", string);
|
||||
return string;
|
||||
}
|
||||
return URLEncoder.encode(string, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -351,7 +346,7 @@ public abstract class AbstractWidgetRenderer implements WidgetRenderer {
|
|||
*
|
||||
* @param w
|
||||
* The widget to process
|
||||
* @param snippet
|
||||
* @param originalSnippet
|
||||
* The snippet to translate
|
||||
* @return The updated snippet
|
||||
*/
|
||||
|
@ -423,9 +418,8 @@ public abstract class AbstractWidgetRenderer implements WidgetRenderer {
|
|||
}
|
||||
|
||||
protected @Nullable String getRGBHexCodeFromItemState(@Nullable State itemState) {
|
||||
if (itemState instanceof HSBType) {
|
||||
HSBType hsbState = (HSBType) itemState;
|
||||
return "#" + Integer.toHexString(hsbState.getRGB()).substring(2);
|
||||
if (itemState instanceof HSBType hsbState) {
|
||||
return "#" + Integer.toHexString(ColorUtil.hsbTosRgb(hsbState)).substring(2);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -185,11 +185,10 @@ public class ButtongridRenderer extends AbstractWidgetRenderer {
|
|||
throws RenderException {
|
||||
String button = getSnippet("button");
|
||||
|
||||
String command = cmd;
|
||||
String label = lab == null ? cmd : lab;
|
||||
|
||||
button = button.replace("%item%", item);
|
||||
button = button.replace("%cmd%", escapeHtml(command));
|
||||
button = button.replace("%cmd%", escapeHtml(cmd));
|
||||
String buttonClass = "buttongrid-button";
|
||||
String style = "";
|
||||
if (icon == null || !config.isIconsEnabled()) {
|
||||
|
|
|
@ -59,7 +59,7 @@ public class ImageRenderer extends AbstractWidgetRenderer {
|
|||
@Override
|
||||
public EList<Widget> renderWidget(Widget w, StringBuilder sb, String sitemap) throws RenderException {
|
||||
Image image = (Image) w;
|
||||
String snippet = (image.getChildren().size() > 0) ? getSnippet("image_link") : getSnippet("image");
|
||||
String snippet = (!image.getChildren().isEmpty()) ? getSnippet("image_link") : getSnippet("image");
|
||||
|
||||
boolean showHeaderRow = image.getLabel() != null;
|
||||
snippet = snippet.replace("%header_visibility_class%",
|
||||
|
|
|
@ -134,7 +134,7 @@ public class InputRenderer extends AbstractWidgetRenderer {
|
|||
State state = itemUIRegistry.getState(w);
|
||||
|
||||
String prefix = getPrefix(w);
|
||||
boolean hasUnit = item instanceof NumberItem ? (((NumberItem) item).getDimension() != null) : false;
|
||||
boolean hasUnit = item instanceof NumberItem && (((NumberItem) item).getDimension() != null);
|
||||
String postfix = hasUnit ? "" : getPostfix(w);
|
||||
String prefixSnippet = !prefix.isBlank()
|
||||
? "<span %valuestyle% class=\"mdl-form__input-prefix\">" + prefix + "</span>"
|
||||
|
@ -181,8 +181,7 @@ public class InputRenderer extends AbstractWidgetRenderer {
|
|||
|
||||
String unitSnippet = "";
|
||||
String unit = "";
|
||||
if (item instanceof NumberItem) {
|
||||
NumberItem numberItem = (NumberItem) item;
|
||||
if (item instanceof NumberItem numberItem) {
|
||||
if (numberItem.getDimension() != null) {
|
||||
unit = getUnit(w, numberItem);
|
||||
if ("number".equals(inputHint)) {
|
||||
|
@ -211,7 +210,7 @@ public class InputRenderer extends AbstractWidgetRenderer {
|
|||
if (COMMA_SEPARATOR_PATTERN.matcher(newValue).find()) {
|
||||
newValue = newValue.replace("/\\./g", "").replace(",", ".");
|
||||
}
|
||||
if (unitValue.length() > 0) {
|
||||
if (!unitValue.isEmpty()) {
|
||||
newValue = newValue + " " + unitValue;
|
||||
}
|
||||
return newValue;
|
||||
|
@ -230,8 +229,7 @@ public class InputRenderer extends AbstractWidgetRenderer {
|
|||
value = "-";
|
||||
}
|
||||
}
|
||||
if (item instanceof NumberItem) {
|
||||
NumberItem numberItem = (NumberItem) item;
|
||||
if (item instanceof NumberItem numberItem) {
|
||||
if (numberItem.getDimension() != null) {
|
||||
String[] stateArray = value.split(" ");
|
||||
if (stateArray.length <= 1) {
|
||||
|
@ -245,7 +243,7 @@ public class InputRenderer extends AbstractWidgetRenderer {
|
|||
|
||||
private String cleanValue(String value, Widget w, Item item) {
|
||||
String prefix = getPrefix(w);
|
||||
boolean hasUnit = item instanceof NumberItem ? (((NumberItem) item).getDimension() != null) : false;
|
||||
boolean hasUnit = item instanceof NumberItem && (((NumberItem) item).getDimension() != null);
|
||||
String postfix = hasUnit ? "" : getPostfix(w);
|
||||
String newValue = value.startsWith(prefix) ? value.substring(prefix.length()) : value;
|
||||
newValue = value.endsWith(postfix) ? newValue.substring(0, newValue.lastIndexOf(postfix)) : newValue;
|
||||
|
|
|
@ -69,8 +69,7 @@ public class MapviewRenderer extends AbstractWidgetRenderer {
|
|||
snippet = processColor(w, snippet);
|
||||
|
||||
State state = itemUIRegistry.getState(mapview);
|
||||
if (state instanceof PointType) {
|
||||
PointType pointState = (PointType) state;
|
||||
if (state instanceof PointType pointState) {
|
||||
double latitude = pointState.getLatitude().doubleValue();
|
||||
double longitude = pointState.getLongitude().doubleValue();
|
||||
snippet = snippet.replace("%url%", MAP_URL);
|
||||
|
|
|
@ -136,12 +136,12 @@ public class PageRenderer extends AbstractWidgetRenderer {
|
|||
return preChildren.append(postChildren);
|
||||
}
|
||||
|
||||
private void processChildren(StringBuilder sb_pre, StringBuilder sb_post, EList<Widget> children, String sitemap)
|
||||
private void processChildren(StringBuilder sbPre, StringBuilder sbPost, EList<Widget> children, String sitemap)
|
||||
throws RenderException {
|
||||
// put a single frame around all children widgets, if there are no explicit frames
|
||||
if (!children.isEmpty()) {
|
||||
EObject firstChild = children.get(0);
|
||||
EObject parent = itemUIRegistry.getParent((Widget) firstChild);
|
||||
Widget firstChild = children.get(0);
|
||||
EObject parent = itemUIRegistry.getParent(firstChild);
|
||||
if (!(firstChild instanceof Frame || parent instanceof Frame || parent instanceof Sitemap)) {
|
||||
String frameSnippet = getSnippet("frame");
|
||||
frameSnippet = frameSnippet.replace("%widget_id%", "");
|
||||
|
@ -150,8 +150,8 @@ public class PageRenderer extends AbstractWidgetRenderer {
|
|||
|
||||
String[] parts = frameSnippet.split("%children%");
|
||||
if (parts.length > 1) {
|
||||
sb_pre.append(parts[0]);
|
||||
sb_post.insert(0, parts[1]);
|
||||
sbPre.append(parts[0]);
|
||||
sbPost.insert(0, parts[1]);
|
||||
}
|
||||
if (parts.length > 2) {
|
||||
logger.error("Snippet 'frame' contains multiple %children% sections, but only one is allowed!");
|
||||
|
@ -185,10 +185,10 @@ public class PageRenderer extends AbstractWidgetRenderer {
|
|||
widgetType);
|
||||
}
|
||||
processChildren(newPre, newPost, nextChildren, sitemap);
|
||||
sb_pre.append(newPre);
|
||||
sb_pre.append(newPost);
|
||||
sbPre.append(newPre);
|
||||
sbPre.append(newPost);
|
||||
} else {
|
||||
sb_pre.append(widgetSB);
|
||||
sbPre.append(widgetSB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class TextRenderer extends AbstractWidgetRenderer {
|
|||
@Override
|
||||
public EList<Widget> renderWidget(Widget w, StringBuilder sb, String sitemap) throws RenderException {
|
||||
Text text = (Text) w;
|
||||
String snippet = (text.getChildren().size() > 0) ? getSnippet("text_link") : getSnippet("text");
|
||||
String snippet = (!text.getChildren().isEmpty()) ? getSnippet("text_link") : getSnippet("text");
|
||||
|
||||
snippet = preprocessSnippet(snippet, w);
|
||||
snippet = snippet.replace("%id%", itemUIRegistry.getWidgetId(w));
|
||||
|
|
|
@ -112,8 +112,8 @@ public class ManagerSettings implements IConfigChangeListener {
|
|||
String[] parts = value.split(":");
|
||||
String source = parts[0];
|
||||
if (!source.contains("..") || (allowLookup && lookupMount.matcher(source).find())) {
|
||||
boolean writeable = parts.length > 1 ? parts[1].contains("w") : false;
|
||||
boolean showSubDirs = parts.length > 1 ? parts[1].contains("s") : false;
|
||||
boolean writeable = parts.length > 1 && parts[1].contains("w");
|
||||
boolean showSubDirs = parts.length > 1 && parts[1].contains("s");
|
||||
if (source.startsWith(File.separator)) {
|
||||
source = source.substring(1);
|
||||
}
|
||||
|
|
|
@ -70,14 +70,12 @@ public class StateBeanMessageBodyWriter implements MessageBodyWriter<Object> {
|
|||
*/
|
||||
public String serialize(Object bean) {
|
||||
String msg = "{\"d\":{";
|
||||
if (bean instanceof StateBean) {
|
||||
StateBean stateBean = (StateBean) bean;
|
||||
if (bean instanceof StateBean stateBean) {
|
||||
msg += "\"" + stateBean.name + "\":\"" + stateBean.state + "\"";
|
||||
} else if (bean instanceof List<?>) {
|
||||
List<String> states = new ArrayList<>();
|
||||
for (Object bo : (List<?>) bean) {
|
||||
if (bo instanceof StateBean) {
|
||||
StateBean stateBean = (StateBean) bo;
|
||||
if (bo instanceof StateBean stateBean) {
|
||||
states.add("\"" + stateBean.name + "\":\"" + stateBean.state + "\"");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -252,8 +252,7 @@ public class ChartResource implements RESTResource {
|
|||
try {
|
||||
List<String> itemNames = new ArrayList<>();
|
||||
|
||||
if (item instanceof GroupItem) {
|
||||
GroupItem groupItem = (GroupItem) item;
|
||||
if (item instanceof GroupItem groupItem) {
|
||||
for (Item member : groupItem.getMembers()) {
|
||||
itemNames.add(member.getName());
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public class DataProviderResource implements RESTResource {
|
|||
// all designs
|
||||
File designDir = ManagerSettings.getInstance().getDesignFolder();
|
||||
File[] designs = designDir.listFiles();
|
||||
List<String> res = new ArrayList<String>();
|
||||
List<String> res = new ArrayList<>();
|
||||
if (designs != null) {
|
||||
Arrays.sort(designs);
|
||||
for (File design : designs) {
|
||||
|
|
|
@ -30,7 +30,6 @@ public interface EventBroadcaster {
|
|||
* Broadcasts an event described by the given parameters to all currently
|
||||
* listening clients.
|
||||
*
|
||||
* @param item the item that should be broadcasted
|
||||
* @param eventObject bean that can be converted to a JSON object.
|
||||
*/
|
||||
void broadcastEvent(final Object eventObject);
|
||||
|
|
|
@ -89,7 +89,7 @@ public class MultipartRequestMap extends HashMap<String, List<Object>> {
|
|||
tempFile.deleteOnExit();
|
||||
|
||||
try (BufferedInputStream input = new BufferedInputStream(part.getInputStream(), 8192);
|
||||
BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(tempFile), 8192);) {
|
||||
BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(tempFile), 8192)) {
|
||||
byte[] buffer = new byte[8192];
|
||||
for (int length = 0; ((length = input.read(buffer)) > 0);) {
|
||||
output.write(buffer, 0, length);
|
||||
|
|
|
@ -127,9 +127,6 @@ public class ReadResource implements EventBroadcaster, RESTResource {
|
|||
* Subscribes the connecting client to the stream of events filtered by the
|
||||
* given eventFilter.
|
||||
*
|
||||
* @param eventFilter
|
||||
* @return {@link EventOutput} object associated with the incoming
|
||||
* connection.
|
||||
* @throws IOException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
|
@ -238,7 +235,6 @@ public class ReadResource implements EventBroadcaster, RESTResource {
|
|||
* Broadcasts an event described by the given parameters to all currently
|
||||
* listening clients.
|
||||
*
|
||||
* @param item the item which has changed
|
||||
* @param eventObject bean that can be converted to a JSON object.
|
||||
*/
|
||||
@Override
|
||||
|
@ -248,9 +244,7 @@ public class ReadResource implements EventBroadcaster, RESTResource {
|
|||
return;
|
||||
}
|
||||
|
||||
executorService.execute(() -> {
|
||||
broadcaster.send(SseUtil.buildEvent(sse.newEventBuilder(), eventObject));
|
||||
});
|
||||
executorService.execute(() -> broadcaster.send(SseUtil.buildEvent(sse.newEventBuilder(), eventObject)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -429,13 +429,8 @@ public class ConfigHelper {
|
|||
setter.invoke(element, label);
|
||||
return label;
|
||||
}
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
} catch (IllegalAccessException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (NoSuchMethodException | SecurityException | InvocationTargetException | IllegalArgumentException
|
||||
| IllegalAccessException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
}
|
||||
return null;
|
||||
|
@ -468,13 +463,8 @@ public class ConfigHelper {
|
|||
Method setter = element.getClass().getMethod("setMapping", String.class);
|
||||
setter.invoke(element, mapping.getName());
|
||||
return mapping;
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
} catch (IllegalAccessException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (NoSuchMethodException | SecurityException | InvocationTargetException | IllegalArgumentException
|
||||
| IllegalAccessException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -628,11 +618,7 @@ public class ConfigHelper {
|
|||
mapping = (EList<org.openhab.core.model.sitemap.sitemap.Mapping>) getter.invoke(widget);
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
// do nothing, normal behaviour for item that have no mappingdefined
|
||||
} catch (IllegalAccessException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
}
|
||||
return mapping;
|
||||
|
@ -641,7 +627,7 @@ public class ConfigHelper {
|
|||
public Mapping addMapping(Object element, Widget widget) {
|
||||
Mapping mapping = null;
|
||||
EList<org.openhab.core.model.sitemap.sitemap.Mapping> smap = getMapping(widget);
|
||||
if (smap != null && smap.size() > 0) {
|
||||
if (smap != null && !smap.isEmpty()) {
|
||||
mapping = addMapping(element, String.valueOf(smap.hashCode()), smap);
|
||||
}
|
||||
|
||||
|
@ -944,13 +930,8 @@ public class ConfigHelper {
|
|||
format = m.group(2);
|
||||
method.invoke(elem, format);
|
||||
}
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
} catch (IllegalAccessException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (NoSuchMethodException | SecurityException | InvocationTargetException | IllegalArgumentException
|
||||
| IllegalAccessException e) {
|
||||
logger.error("{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -973,10 +954,9 @@ public class ConfigHelper {
|
|||
List<JAXBElement<?>> childsToAdd = new ArrayList<>();
|
||||
List<JAXBElement<?>> groupsToDelete = new ArrayList<>();
|
||||
for (JAXBElement<?> element : children) {
|
||||
if (element.getValue() instanceof Page) {
|
||||
if (element.getValue() instanceof Page p) {
|
||||
// check if this page only has invisible subpages and a pagejump
|
||||
// in the navbar => change the pagejump to the first subpage
|
||||
Page p = (Page) element.getValue();
|
||||
int visible = 0;
|
||||
Page firstChildPage = null;
|
||||
for (JAXBElement<?> ge : p.getPageOrGroupOrNavbar()) {
|
||||
|
@ -995,11 +975,9 @@ public class ConfigHelper {
|
|||
if (visible == 0 && firstChildPage != null) {
|
||||
// find the pagejumps (only on the root page)
|
||||
for (JAXBElement<?> e : pages.getPage().getPageOrGroupOrNavbar()) {
|
||||
if (e.getValue() instanceof Navbar) {
|
||||
Navbar navbar = (Navbar) e.getValue();
|
||||
if (e.getValue() instanceof Navbar navbar) {
|
||||
for (JAXBElement<?> ne : navbar.getPageOrGroupOrLine()) {
|
||||
if (ne.getValue() instanceof Pagejump) {
|
||||
Pagejump pj = (Pagejump) ne.getValue();
|
||||
if (ne.getValue() instanceof Pagejump pj) {
|
||||
if (pj.getTarget().equals(p.getName())) {
|
||||
pj.setTarget(firstChildPage.getName());
|
||||
}
|
||||
|
@ -1009,16 +987,14 @@ public class ConfigHelper {
|
|||
}
|
||||
}
|
||||
cleanup(element.getValue(), pages);
|
||||
} else if (element.getValue() instanceof Group) {
|
||||
Group group = (Group) element.getValue();
|
||||
} else if (element.getValue() instanceof Group group) {
|
||||
// check for visible elements
|
||||
int visible = 0;
|
||||
for (JAXBElement<?> ge : group.getPageOrGroupOrLine()) {
|
||||
if (ge == null || ge.getValue() == null) {
|
||||
continue;
|
||||
}
|
||||
if (ge.getValue() instanceof Page) {
|
||||
Page p = (Page) ge.getValue();
|
||||
if (ge.getValue() instanceof Page p) {
|
||||
if (p.isVisible() == null || p.isVisible().booleanValue()) {
|
||||
visible++;
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ public class VisuConfig {
|
|||
classes[0] = bean.getClass();
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(bean.getClass());
|
||||
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||
Schema schema = (xsdSchema == null || xsdSchema.trim().length() == 0) ? null
|
||||
Schema schema = (xsdSchema == null || xsdSchema.trim().isEmpty()) ? null
|
||||
: schemaFactory.newSchema(new File(xsdSchema));
|
||||
Marshaller marshaller = jaxbContext.createMarshaller();
|
||||
marshaller.setSchema(schema);
|
||||
|
@ -153,9 +153,7 @@ public class VisuConfig {
|
|||
StringWriter sw = new StringWriter();
|
||||
marshaller.marshal(bean, sw);
|
||||
res = sw.toString();
|
||||
} catch (JAXBException e) {
|
||||
logger.error("{}", e.getMessage(), e);
|
||||
} catch (SAXException e) {
|
||||
} catch (JAXBException | SAXException e) {
|
||||
logger.error("{}", e.getMessage(), e);
|
||||
}
|
||||
return res;
|
||||
|
@ -206,7 +204,7 @@ public class VisuConfig {
|
|||
|
||||
if (widget instanceof LinkableWidget) {
|
||||
EList<Widget> children = app.getItemUIRegistry().getChildren((LinkableWidget) widget);
|
||||
if (children.size() == 0) {
|
||||
if (children.isEmpty()) {
|
||||
processItemWidget(rootPage, widget, item, pages, level);
|
||||
} else if (widget instanceof org.openhab.core.model.sitemap.sitemap.Frame) {
|
||||
Group group = new Group();
|
||||
|
@ -220,8 +218,7 @@ public class VisuConfig {
|
|||
Page page = new Page();
|
||||
page.setName(configHelper.getLabel(widget));
|
||||
configHelper.addToRoot(rootPage, factory.createPagePage(page));
|
||||
if (widget instanceof org.openhab.core.model.sitemap.sitemap.Group) {
|
||||
org.openhab.core.model.sitemap.sitemap.Group group = (org.openhab.core.model.sitemap.sitemap.Group) widget;
|
||||
if (widget instanceof org.openhab.core.model.sitemap.sitemap.Group group) {
|
||||
// add Group item to the Navbar
|
||||
// logger.debug("page '{}' on level {}",page.getName(),level);
|
||||
NavbarPositionType position = (level <= 1) ? NavbarPositionType.TOP : NavbarPositionType.LEFT;
|
||||
|
@ -247,17 +244,16 @@ public class VisuConfig {
|
|||
}
|
||||
|
||||
private void processItemWidget(Object rootPage, Widget widget, Item item, Pages pages, int level) {
|
||||
if (widget instanceof org.openhab.core.model.sitemap.sitemap.Switch) {
|
||||
if (widget instanceof org.openhab.core.model.sitemap.sitemap.Switch switchWidget) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
org.openhab.core.model.sitemap.sitemap.Switch switchWidget = (org.openhab.core.model.sitemap.sitemap.Switch) widget;
|
||||
|
||||
if (item instanceof RollershutterItem) {
|
||||
// in the demo-sitemap a rullershutter item is defined as
|
||||
// switch???
|
||||
configHelper.addRollershutter(rootPage, item, switchWidget);
|
||||
} else if (switchWidget.getMappings().size() > 0) {
|
||||
} else if (!switchWidget.getMappings().isEmpty()) {
|
||||
// up to 5 mapping we can use a multitrigger
|
||||
if (switchWidget.getMappings().size() <= 4) {
|
||||
configHelper.mapToMultiTrigger(rootPage, item, switchWidget);
|
||||
|
@ -315,11 +311,10 @@ public class VisuConfig {
|
|||
configHelper.addAddress(bean, item, Transform.DIMMER);
|
||||
configHelper.addLabel(bean, widget);
|
||||
configHelper.addToRoot(rootPage, factory.createPageSlide(bean));
|
||||
} else if (widget instanceof Setpoint) {
|
||||
} else if (widget instanceof Setpoint setpoint) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
Setpoint setpoint = (Setpoint) widget;
|
||||
Slide bean = new Slide();
|
||||
bean.setFormat("%d");
|
||||
bean.setMin(setpoint.getMinValue());
|
||||
|
@ -330,11 +325,10 @@ public class VisuConfig {
|
|||
configHelper.addLabel(bean, widget);
|
||||
|
||||
configHelper.addToRoot(rootPage, factory.createPageSlide(bean));
|
||||
} else if (widget instanceof Selection) {
|
||||
} else if (widget instanceof Selection selection) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
Selection selection = (Selection) widget;
|
||||
// Map a Selection to a Group of triggers
|
||||
Group bean = new Group();
|
||||
bean.setNowidget(true);
|
||||
|
@ -356,8 +350,7 @@ public class VisuConfig {
|
|||
}
|
||||
|
||||
configHelper.addToRoot(rootPage, factory.createPageGroup(bean));
|
||||
} else if (widget instanceof Webview) {
|
||||
Webview webview = (Webview) widget;
|
||||
} else if (widget instanceof Webview webview) {
|
||||
Web bean = new Web();
|
||||
bean.setHeight(String.valueOf(webview.getHeight()) + "%");
|
||||
bean.setWidth("100%");
|
||||
|
@ -367,8 +360,7 @@ public class VisuConfig {
|
|||
configHelper.addLabel(bean, widget);
|
||||
|
||||
configHelper.addToRoot(rootPage, factory.createPageWeb(bean));
|
||||
} else if (widget instanceof org.openhab.core.model.sitemap.sitemap.Image) {
|
||||
org.openhab.core.model.sitemap.sitemap.Image image = (org.openhab.core.model.sitemap.sitemap.Image) widget;
|
||||
} else if (widget instanceof org.openhab.core.model.sitemap.sitemap.Image image) {
|
||||
Image bean = new Image();
|
||||
bean.setSrc(image.getUrl());
|
||||
bean.setRefresh(new BigDecimal(image.getRefresh()));
|
||||
|
@ -376,22 +368,20 @@ public class VisuConfig {
|
|||
configHelper.addLabel(bean, widget);
|
||||
|
||||
configHelper.addToRoot(rootPage, factory.createPageImage(bean));
|
||||
} else if (widget instanceof org.openhab.core.model.sitemap.sitemap.Video) {
|
||||
org.openhab.core.model.sitemap.sitemap.Video video = (org.openhab.core.model.sitemap.sitemap.Video) widget;
|
||||
} else if (widget instanceof org.openhab.core.model.sitemap.sitemap.Video video) {
|
||||
Video bean = new Video();
|
||||
bean.setSrc(video.getUrl());
|
||||
|
||||
configHelper.addLabel(bean, widget);
|
||||
|
||||
configHelper.addToRoot(rootPage, factory.createPageVideo(bean));
|
||||
} else if (widget instanceof org.openhab.core.model.sitemap.sitemap.Chart && item != null) {
|
||||
} else if (widget instanceof org.openhab.core.model.sitemap.sitemap.Chart chart && item != null) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
Plugin plugin = new Plugin();
|
||||
plugin.setName("diagram");
|
||||
configHelper.addPlugin(plugin);
|
||||
org.openhab.core.model.sitemap.sitemap.Chart chart = (org.openhab.core.model.sitemap.sitemap.Chart) widget;
|
||||
Diagram bean = new Diagram();
|
||||
bean.setSeries(configHelper.getCvChartPeriod(chart.getPeriod()));
|
||||
bean.setRefresh(new BigInteger(String.valueOf(chart.getRefresh())));
|
||||
|
|
|
@ -196,11 +196,11 @@ public class CometVisuApp {
|
|||
Object propertyValue = properties.get(Config.COMETVISU_AUTODOWNLOAD_PROPERTY);
|
||||
|
||||
// Value might be a string or a boolean
|
||||
Boolean newValue = false;
|
||||
if (propertyValue instanceof String) {
|
||||
newValue = Boolean.valueOf((String) propertyValue);
|
||||
} else if (propertyValue instanceof Boolean) {
|
||||
newValue = (Boolean) propertyValue;
|
||||
boolean newValue = false;
|
||||
if (propertyValue instanceof String s) {
|
||||
newValue = Boolean.parseBoolean(s);
|
||||
} else if (propertyValue instanceof Boolean b) {
|
||||
newValue = b;
|
||||
}
|
||||
|
||||
boolean changed = Config.cometvisuAutoDownload != newValue;
|
||||
|
@ -237,9 +237,7 @@ public class CometVisuApp {
|
|||
* Called by the SCR to activate the component with its configuration read
|
||||
* from CAS
|
||||
*
|
||||
* @param bundleContext
|
||||
* BundleContext of the Bundle that defines this component
|
||||
* @param configuration
|
||||
* @param configProps
|
||||
* Configuration properties for this component obtained from the
|
||||
* ConfigAdmin service
|
||||
*/
|
||||
|
@ -272,9 +270,7 @@ public class CometVisuApp {
|
|||
servlet = new CometVisuServlet(Config.cometvisuWebfolder, this);
|
||||
try {
|
||||
httpService.registerServlet(Config.cometvisuWebappAlias, servlet, servletParams, null);
|
||||
} catch (ServletException e) {
|
||||
logger.error("Error during servlet startup", e);
|
||||
} catch (NamespaceException e) {
|
||||
} catch (ServletException | NamespaceException e) {
|
||||
logger.error("Error during servlet startup", e);
|
||||
}
|
||||
}
|
||||
|
@ -287,7 +283,7 @@ public class CometVisuApp {
|
|||
* Called by the SCR when the configuration of a binding has been changed
|
||||
* through the ConfigAdmin service.
|
||||
*
|
||||
* @param configuration
|
||||
* @param configProps
|
||||
* Updated configuration properties
|
||||
*/
|
||||
@Modified
|
||||
|
|
|
@ -22,13 +22,12 @@ import java.io.PrintWriter;
|
|||
import java.io.RandomAccessFile;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -188,21 +187,18 @@ public class CometVisuServlet extends HttpServlet {
|
|||
if (requestedFile.endsWith("/")) {
|
||||
requestedFile = requestedFile.substring(0, requestedFile.length() - 1);
|
||||
}
|
||||
file = new File(userFileFolder, URLDecoder.decode(requestedFile, "UTF-8"));
|
||||
file = new File(userFileFolder, URLDecoder.decode(requestedFile, StandardCharsets.UTF_8));
|
||||
}
|
||||
// serve the file from the cometvisu src directory
|
||||
if (file == null || !file.exists() || file.isDirectory()) {
|
||||
file = requestedFile != null ? new File(rootFolder, URLDecoder.decode(requestedFile, "UTF-8")) : rootFolder;
|
||||
file = requestedFile != null
|
||||
? new File(rootFolder, URLDecoder.decode(requestedFile, StandardCharsets.UTF_8))
|
||||
: rootFolder;
|
||||
}
|
||||
if (file.isDirectory()) {
|
||||
// search for an index file
|
||||
FilenameFilter filter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(@Nullable File dir, @Nullable String name) {
|
||||
return name != null && name.startsWith("index.")
|
||||
&& (name.endsWith(".php") || name.endsWith(".html"));
|
||||
}
|
||||
};
|
||||
FilenameFilter filter = (dir, name) -> name != null && name.startsWith("index.")
|
||||
&& (name.endsWith(".php") || name.endsWith(".html"));
|
||||
for (String dirFile : file.list(filter)) {
|
||||
// take the first one found
|
||||
file = new File(file, dirFile);
|
||||
|
@ -363,14 +359,7 @@ public class CometVisuServlet extends HttpServlet {
|
|||
if ("rrd4j".equals(persistenceService.getId())
|
||||
&& FilterCriteria.Ordering.DESCENDING.equals(filter.getOrdering())) {
|
||||
// the RRD4j PersistenceService does not support descending ordering so we do it manually
|
||||
Collections.sort(feed.entries,
|
||||
new Comparator<org.openhab.ui.cometvisu.internal.backend.model.rss.Entry>() {
|
||||
@Override
|
||||
public int compare(org.openhab.ui.cometvisu.internal.backend.model.rss.Entry o1,
|
||||
org.openhab.ui.cometvisu.internal.backend.model.rss.Entry o2) {
|
||||
return Long.compare(o2.publishedDate, o1.publishedDate);
|
||||
}
|
||||
});
|
||||
feed.entries.sort((o1, o2) -> Long.compare(o2.publishedDate, o1.publishedDate));
|
||||
}
|
||||
logger.debug("querying {} item from {} to {} => {} results on service {}", filter.getItemName(),
|
||||
filter.getBeginDate(), filter.getEndDate(), i, persistenceService.getId());
|
||||
|
@ -447,7 +436,7 @@ public class CometVisuServlet extends HttpServlet {
|
|||
// URL-decode the file name (might contain spaces and on) and
|
||||
// prepare
|
||||
// file object.
|
||||
processFile = new File(rootFolder, URLDecoder.decode(requestedFile, "UTF-8"));
|
||||
processFile = new File(rootFolder, URLDecoder.decode(requestedFile, StandardCharsets.UTF_8));
|
||||
} else {
|
||||
processFile = file;
|
||||
}
|
||||
|
@ -459,7 +448,7 @@ public class CometVisuServlet extends HttpServlet {
|
|||
if (!processFile.exists()) {
|
||||
// show installation hints if the CometVisu-Clients main index.html is requested but cannot be found
|
||||
if (processFile.getParentFile().equals(rootFolder)
|
||||
&& (processFile.getName().equalsIgnoreCase("index.html") || processFile.getName().length() == 0)) {
|
||||
&& (processFile.getName().equalsIgnoreCase("index.html") || processFile.getName().isEmpty())) {
|
||||
// looking for CometVisu clients index.html file
|
||||
String path = null;
|
||||
File folder = processFile.isDirectory() ? processFile : processFile.getParentFile();
|
||||
|
@ -657,15 +646,14 @@ public class CometVisuServlet extends HttpServlet {
|
|||
|
||||
if (ranges.isEmpty() || ranges.get(0).equals(full)) {
|
||||
// Return full file.
|
||||
Range r = full;
|
||||
response.setContentType(contentType);
|
||||
response.setHeader("Content-Range", "bytes " + r.start + "-" + r.end + "/" + r.total);
|
||||
response.setHeader("Content-Range", "bytes " + full.start + "-" + full.end + "/" + full.total);
|
||||
|
||||
if (content) {
|
||||
response.setHeader("HA", String.valueOf(r.length));
|
||||
response.setHeader("HA", String.valueOf(full.length));
|
||||
|
||||
// Copy full range.
|
||||
copy(input, output, r.start, r.length);
|
||||
copy(input, output, full.start, full.length);
|
||||
}
|
||||
} else if (ranges.size() == 1) {
|
||||
// Return single part of file.
|
||||
|
@ -801,7 +789,7 @@ public class CometVisuServlet extends HttpServlet {
|
|||
*/
|
||||
private static long sublong(String value, int beginIndex, int endIndex) {
|
||||
String substring = value.substring(beginIndex, endIndex);
|
||||
return (substring.length() > 0) ? Long.parseLong(substring) : -1;
|
||||
return (!substring.isEmpty()) ? Long.parseLong(substring) : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -863,7 +851,7 @@ public class CometVisuServlet extends HttpServlet {
|
|||
/**
|
||||
* This class represents a byte range.
|
||||
*/
|
||||
protected class Range {
|
||||
protected static class Range {
|
||||
long start;
|
||||
long end;
|
||||
long length;
|
||||
|
|
|
@ -234,10 +234,9 @@ public class ClientInstaller {
|
|||
List<Map<String, Object>> jsonResponse = new Gson().fromJson(response, ArrayList.class);
|
||||
|
||||
// releases are ordered top-down, the latest release comes first
|
||||
for (int i = 0; i < jsonResponse.size(); i++) {
|
||||
var release = jsonResponse.get(i);
|
||||
if (((boolean) release.getOrDefault("prerelease", true)) == false
|
||||
&& ((boolean) release.getOrDefault("draft", true)) == false) {
|
||||
for (Map<String, Object> release : jsonResponse) {
|
||||
if (!((boolean) release.getOrDefault("prerelease", true))
|
||||
&& !((boolean) release.getOrDefault("draft", true))) {
|
||||
latestRelease = release;
|
||||
break;
|
||||
}
|
||||
|
@ -259,8 +258,7 @@ public class ClientInstaller {
|
|||
List<Map<String, Object>> assets = (List<Map<String, Object>>) latestRelease.get("assets");
|
||||
|
||||
Map<String, Object> releaseAsset = null;
|
||||
for (Object assetObj : assets) {
|
||||
Map<String, Object> asset = (Map<String, Object>) assetObj;
|
||||
for (Map<String, Object> asset : assets) {
|
||||
String contentType = ((String) asset.getOrDefault("content_type", ""));
|
||||
String name = ((String) asset.getOrDefault("name", ""));
|
||||
if (contentType.equalsIgnoreCase("application/zip")
|
||||
|
@ -313,8 +311,7 @@ public class ClientInstaller {
|
|||
}
|
||||
new File(file.getParent()).mkdirs();
|
||||
|
||||
try (InputStream is = zipFile.getInputStream(entry);
|
||||
OutputStream os = new FileOutputStream(file);) {
|
||||
try (InputStream is = zipFile.getInputStream(entry); OutputStream os = new FileOutputStream(file)) {
|
||||
for (int len; (len = is.read(BUFFER)) != -1;) {
|
||||
os.write(BUFFER, 0, len);
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ public class FsUtil {
|
|||
* @return A list of MointPoints that are mounted as directories in this path
|
||||
*/
|
||||
public ArrayList<MountPoint> getMounts(Path path) {
|
||||
ArrayList<MountPoint> mounts = new ArrayList<MountPoint>();
|
||||
ArrayList<MountPoint> mounts = new ArrayList<>();
|
||||
for (final MountPoint mount : ManagerSettings.getInstance().getMounts()) {
|
||||
if (mount.getAbsoluteTarget().startsWith(path)) {
|
||||
mounts.add(mount);
|
||||
|
@ -248,7 +248,7 @@ public class FsUtil {
|
|||
entry.setName(file.getName());
|
||||
entry.setHasChildren(file.isDirectory() && file.listFiles().length > 0);
|
||||
entry.setParentFolder(mount.getPath());
|
||||
entry.setWriteable(mount.isReadonlyMount() ? false : file.canWrite());
|
||||
entry.setWriteable(!mount.isReadonlyMount() && file.canWrite());
|
||||
entry.setReadable(file.canRead());
|
||||
entry.setMounted(false);
|
||||
entry.setInTrash(this.isInTrash(file));
|
||||
|
|
|
@ -31,12 +31,11 @@ import org.openhab.ui.cometvisu.internal.backend.model.StateBean;
|
|||
public class SseUtil {
|
||||
|
||||
/**
|
||||
* Creates a new {@link OutboundEvent} object containing an
|
||||
* Creates a new {@link OutboundSseEvent} object containing an
|
||||
* {@link StateBean} created for the given eventType, objectIdentifier,
|
||||
* eventObject.
|
||||
*
|
||||
* @param eventType the event type for the event
|
||||
* @param objectIdentifier the identifier for the main event object
|
||||
* @param eventBuilder the builder used for building the event
|
||||
* @param eventObject the eventObject to be included
|
||||
* @return a new OutboundSseEvent
|
||||
*/
|
||||
|
@ -51,12 +50,7 @@ public class SseUtil {
|
|||
* Used to mark our current thread(request processing) that SSE blocking
|
||||
* should be enabled.
|
||||
*/
|
||||
private static ThreadLocal<Boolean> blockingSseEnabled = new ThreadLocal<>() {
|
||||
@Override
|
||||
protected Boolean initialValue() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
private static ThreadLocal<Boolean> blockingSseEnabled = ThreadLocal.withInitial(() -> false);
|
||||
|
||||
/**
|
||||
* Returns true if the current thread is processing an SSE request that
|
||||
|
|
|
@ -41,10 +41,10 @@ public class Card extends Component implements Identifiable<String> {
|
|||
@Nullable
|
||||
String subtitle;
|
||||
|
||||
Set<String> objects = new HashSet<String>();
|
||||
Set<String> locations = new HashSet<String>();
|
||||
Set<String> objects = new HashSet<>();
|
||||
Set<String> locations = new HashSet<>();
|
||||
|
||||
Set<String> tags = new HashSet<String>();
|
||||
Set<String> tags = new HashSet<>();
|
||||
|
||||
boolean bookmarked;
|
||||
boolean notReuseableInChat;
|
||||
|
@ -213,7 +213,7 @@ public class Card extends Component implements Identifiable<String> {
|
|||
* Specifies whether the card is ephemeral, meaning it is not saved permanently to the @link {@link CardRegistry}
|
||||
* and will be purged once a number of newer ephemeral cards are added
|
||||
*
|
||||
* @return true if the card is ephemeral, false (default) otherwise
|
||||
* @param ephemeral true if the card is ephemeral, false (default) otherwise
|
||||
*/
|
||||
public void setEphemeral(boolean ephemeral) {
|
||||
this.ephemeral = ephemeral;
|
||||
|
@ -300,7 +300,7 @@ public class Card extends Component implements Identifiable<String> {
|
|||
/**
|
||||
* Adds an object attribute to the card
|
||||
*
|
||||
* @param tag the tag to add
|
||||
* @param object the object to add
|
||||
*/
|
||||
public void addObjectAttribute(String object) {
|
||||
this.objects.add(object);
|
||||
|
@ -309,7 +309,7 @@ public class Card extends Component implements Identifiable<String> {
|
|||
/**
|
||||
* Adds several object attributes to the card
|
||||
*
|
||||
* @param tags the tags to add
|
||||
* @param objects the objects to add
|
||||
*/
|
||||
public void addObjectAttributes(Collection<String> objects) {
|
||||
this.objects.addAll(objects);
|
||||
|
@ -318,7 +318,7 @@ public class Card extends Component implements Identifiable<String> {
|
|||
/**
|
||||
* Adds several object attributes to the card
|
||||
*
|
||||
* @param tags the tags to add
|
||||
* @param objects the objects to add
|
||||
*/
|
||||
public void addObjectAttributes(String... objects) {
|
||||
this.objects.addAll(Arrays.asList(objects));
|
||||
|
@ -327,7 +327,7 @@ public class Card extends Component implements Identifiable<String> {
|
|||
/**
|
||||
* Removes an object attribute on a card
|
||||
*
|
||||
* @param tag the tag to remove
|
||||
* @param object the object to remove
|
||||
*/
|
||||
public void removeObjectAttribute(String object) {
|
||||
this.objects.remove(object);
|
||||
|
@ -348,7 +348,7 @@ public class Card extends Component implements Identifiable<String> {
|
|||
/**
|
||||
* Adds an location attribute to the card
|
||||
*
|
||||
* @param tag the tag to add
|
||||
* @param location the location to add
|
||||
*/
|
||||
public void addLocationAttribute(String location) {
|
||||
this.locations.add(location);
|
||||
|
@ -357,7 +357,7 @@ public class Card extends Component implements Identifiable<String> {
|
|||
/**
|
||||
* Adds several object attributes to the card
|
||||
*
|
||||
* @param tags the tags to add
|
||||
* @param locations the locations to add
|
||||
*/
|
||||
public void addLocationAttributes(Collection<String> locations) {
|
||||
this.locations.addAll(locations);
|
||||
|
@ -366,7 +366,7 @@ public class Card extends Component implements Identifiable<String> {
|
|||
/**
|
||||
* Adds several object attributes to the card
|
||||
*
|
||||
* @param tags the tags to add
|
||||
* @param locations the locations to add
|
||||
*/
|
||||
public void addLocationAttributes(String... locations) {
|
||||
this.locations.addAll(Arrays.asList(locations));
|
||||
|
@ -375,7 +375,7 @@ public class Card extends Component implements Identifiable<String> {
|
|||
/**
|
||||
* Removes an object attribute on a card
|
||||
*
|
||||
* @param tag the tag to remove
|
||||
* @param location the location to remove
|
||||
*/
|
||||
public void removeLocationAttribute(String location) {
|
||||
this.locations.remove(location);
|
||||
|
@ -384,7 +384,7 @@ public class Card extends Component implements Identifiable<String> {
|
|||
/**
|
||||
* Returns whether the card has the specified location attribute
|
||||
*
|
||||
* @param object
|
||||
* @param location
|
||||
*/
|
||||
public boolean hasLocationAttribute(@Nullable String location) {
|
||||
if (this.locations == null || location == null || location.isEmpty()) {
|
||||
|
|
|
@ -15,7 +15,7 @@ package org.openhab.ui.habot.card;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.IllegalFormatConversionException;
|
||||
import java.util.Optional;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
@ -34,7 +34,6 @@ import org.openhab.core.types.State;
|
|||
import org.openhab.core.types.StateDescription;
|
||||
import org.openhab.ui.habot.card.internal.CardRegistry;
|
||||
import org.openhab.ui.habot.nlp.Intent;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.service.component.annotations.Activate;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
|
||||
|
@ -76,7 +75,7 @@ public class CardBuilder {
|
|||
String location = intent.getEntities().get("location");
|
||||
|
||||
Collection<Card> cardsInRegistry = this.cardRegistry.getCardMatchingAttributes(object, location).stream()
|
||||
.filter(c -> !c.isNotReuseableInChat() && !c.isEphemeral()).collect(Collectors.toList());
|
||||
.filter(c -> !c.isNotReuseableInChat() && !c.isEphemeral()).toList();
|
||||
if (!cardsInRegistry.isEmpty()) {
|
||||
// don't handle multiple cards, just return the first one
|
||||
Card existingCard = cardsInRegistry.iterator().next();
|
||||
|
@ -307,14 +306,13 @@ public class CardBuilder {
|
|||
}
|
||||
} else {
|
||||
card.setTitle(intent.getEntities().entrySet().stream().filter(e -> !e.getKey().equals("period"))
|
||||
.map(e -> e.getValue()).collect(Collectors.joining(", ")));
|
||||
.map(Map.Entry::getValue).collect(Collectors.joining(", ")));
|
||||
}
|
||||
card.setSubtitle(period + " - " + matchingNonGroupItems.get().count() + " items"); // TODO: i18n
|
||||
}
|
||||
|
||||
Component chart = new Component("HbChartImage");
|
||||
chart.addConfig("items",
|
||||
matchingNonGroupItems.get().map(i -> i.getName()).collect(Collectors.toList()).toArray(new String[0]));
|
||||
chart.addConfig("items", matchingNonGroupItems.get().map(Item::getName).toArray(String[]::new));
|
||||
chart.addConfig("period", period);
|
||||
|
||||
Component analyzeButton = new Component("HbAnalyzeActionButton");
|
||||
|
@ -336,11 +334,10 @@ public class CardBuilder {
|
|||
* @return an optional group eligible for the card's title, or null if none was found
|
||||
*/
|
||||
private @Nullable GroupItem getMatchingGroup(Collection<Item> items) {
|
||||
Optional<Item> groupItem = items.stream().filter(i -> i instanceof GroupItem)
|
||||
return (GroupItem) items.stream().filter(GroupItem.class::isInstance)
|
||||
.filter(g -> items.stream().allMatch(i -> i.getName().equals(g.getName())
|
||||
|| ((GroupItem) g).getAllMembers().stream().anyMatch(i2 -> i2.getName().contains(i.getName()))))
|
||||
.findFirst();
|
||||
return groupItem.isPresent() ? (GroupItem) groupItem.get() : null;
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
private String formatState(Item item, State state) throws TransformationException {
|
||||
|
@ -350,9 +347,7 @@ public class CardBuilder {
|
|||
if (stateDescription != null) {
|
||||
final String pattern = stateDescription.getPattern();
|
||||
if (pattern != null) {
|
||||
String transformedState = TransformationHelper.transform(
|
||||
FrameworkUtil.getBundle(CardBuilder.class).getBundleContext(), pattern,
|
||||
state.toString());
|
||||
String transformedState = TransformationHelper.transform(pattern, state.toString());
|
||||
if (transformedState == null) {
|
||||
return state.toString();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class Component {
|
|||
public Component(String componentName) {
|
||||
super();
|
||||
this.component = componentName;
|
||||
this.config = new HashMap<String, Object>();
|
||||
this.config = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,9 +94,9 @@ public class Component {
|
|||
*/
|
||||
public List<Component> addSlot(String slotName) {
|
||||
if (slots == null) {
|
||||
slots = new HashMap<String, List<Component>>();
|
||||
slots = new HashMap<>();
|
||||
}
|
||||
List<Component> newSlot = new ArrayList<Component>();
|
||||
List<Component> newSlot = new ArrayList<>();
|
||||
this.slots.put(slotName, newSlot);
|
||||
|
||||
return newSlot;
|
||||
|
|
|
@ -66,7 +66,7 @@ public class CardRegistry extends AbstractRegistry<Card, String, CardProvider> {
|
|||
* @return matching cards
|
||||
*/
|
||||
public Collection<Card> getCardByTags(Set<String> tags) {
|
||||
List<Card> filteredCards = new ArrayList<Card>();
|
||||
List<Card> filteredCards = new ArrayList<>();
|
||||
for (Card card : getAll()) {
|
||||
if (cardHasTags(card, tags)) {
|
||||
filteredCards.add(card);
|
||||
|
@ -84,7 +84,7 @@ public class CardRegistry extends AbstractRegistry<Card, String, CardProvider> {
|
|||
* both are provided, matching cards have both.
|
||||
*/
|
||||
public Collection<Card> getCardMatchingAttributes(@Nullable String object, @Nullable String location) {
|
||||
List<Card> filteredCards = new ArrayList<Card>();
|
||||
List<Card> filteredCards = new ArrayList<>();
|
||||
for (Card card : getAll()) {
|
||||
if (cardMatchesAttributes(card, object, location)) {
|
||||
filteredCards.add(card);
|
||||
|
@ -96,8 +96,7 @@ public class CardRegistry extends AbstractRegistry<Card, String, CardProvider> {
|
|||
@Override
|
||||
public Card add(Card element) {
|
||||
// Remove old ephemeral cards
|
||||
List<Card> oldCards = getAll().stream().filter(card -> card.isEphemeral()).sorted(byTimestamp).skip(10)
|
||||
.collect(Collectors.toList());
|
||||
List<Card> oldCards = getAll().stream().filter(Card::isEphemeral).sorted(byTimestamp).skip(10).toList();
|
||||
|
||||
for (Card card : oldCards) {
|
||||
logger.debug("Removing old ephemeral card {}", card.getUID());
|
||||
|
@ -116,10 +115,8 @@ public class CardRegistry extends AbstractRegistry<Card, String, CardProvider> {
|
|||
*/
|
||||
public Collection<Card> getRecent(int skip, int count) {
|
||||
int limit = (count < 1) ? 10 : count;
|
||||
List<Card> recentCards = getAll().stream().sorted(byTimestamp).skip(skip).limit(limit)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return recentCards;
|
||||
return getAll().stream().sorted(byTimestamp).skip(skip).limit(limit).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,8 +60,7 @@ public abstract class AbstractItemIntentInterpreter implements Skill {
|
|||
|
||||
// expand group items
|
||||
for (Item item : items.toArray(new Item[0])) {
|
||||
if (item instanceof GroupItem) {
|
||||
GroupItem gItem = (GroupItem) item;
|
||||
if (item instanceof GroupItem gItem) {
|
||||
items.addAll(gItem.getMembers());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class Intent {
|
|||
/**
|
||||
* Sets the intent's entities
|
||||
*
|
||||
* @param slots the map of entities
|
||||
* @param entities the map of entities
|
||||
*/
|
||||
public void setEntities(Map<String, String> entities) {
|
||||
this.entities = entities;
|
||||
|
@ -66,6 +66,6 @@ public class Intent {
|
|||
*/
|
||||
public Intent(String name) {
|
||||
this.name = name;
|
||||
this.entities = new HashMap<String, String>();
|
||||
this.entities = new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class IntentDocumentSampleStream implements ObjectStream<DocumentSample>
|
|||
String[] tokens = WhitespaceTokenizer.INSTANCE.tokenize(sampleString);
|
||||
|
||||
// remove entities
|
||||
Vector<String> vector = new Vector<String>(tokens.length);
|
||||
Vector<String> vector = new Vector<>(tokens.length);
|
||||
// boolean skip = false;
|
||||
for (String token : tokens) {
|
||||
if (!token.startsWith("<")) {
|
||||
|
|
|
@ -183,7 +183,7 @@ public class IntentTrainer {
|
|||
intent.getEntities().put(spans[i].getType(), names[i]);
|
||||
}
|
||||
|
||||
logger.debug("{}", intent.toString());
|
||||
logger.debug("{}", intent);
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ public class NamedAttributesItemResolver implements ItemResolver {
|
|||
}
|
||||
|
||||
return (object != null && location != null) ? objectMatch && locationMatch : objectMatch || locationMatch;
|
||||
}).map(entry -> entry.getKey());
|
||||
}).map(Map.Entry::getKey);
|
||||
}
|
||||
|
||||
private void updateItemNamedAttributes() {
|
||||
|
|
|
@ -15,7 +15,7 @@ package org.openhab.ui.habot.nlp.internal;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Comparator;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
@ -142,7 +142,7 @@ public class OpenNLPInterpreter implements HumanLanguageInterpreter {
|
|||
StringBuilder nameSamplesDoc = new StringBuilder();
|
||||
Map<Item, Set<ItemNamedAttribute>> itemAttributes = itemResolver.getAllItemNamedAttributes();
|
||||
|
||||
Stream<ItemNamedAttribute> attributes = itemAttributes.values().stream().flatMap(a -> a.stream());
|
||||
Stream<ItemNamedAttribute> attributes = itemAttributes.values().stream().flatMap(Collection::stream);
|
||||
|
||||
attributes.forEach(attribute -> {
|
||||
if (attribute.getType() == AttributeType.LOCATION) {
|
||||
|
@ -168,20 +168,15 @@ public class OpenNLPInterpreter implements HumanLanguageInterpreter {
|
|||
if (!locale.equals(currentLocale) || intentTrainer == null) {
|
||||
try {
|
||||
itemResolver.setLocale(locale);
|
||||
intentTrainer = new IntentTrainer(locale.getLanguage(),
|
||||
skills.values().stream().sorted(new Comparator<>() {
|
||||
|
||||
@Override
|
||||
public int compare(Skill o1, Skill o2) {
|
||||
if (o1.getIntentId().equals("get-status")) {
|
||||
return -1;
|
||||
}
|
||||
if (o2.getIntentId().equals("get-status")) {
|
||||
return 1;
|
||||
}
|
||||
return o1.getIntentId().compareTo(o2.getIntentId());
|
||||
}
|
||||
}).collect(Collectors.toList()), getNameSamples(), this.tokenizerId);
|
||||
intentTrainer = new IntentTrainer(locale.getLanguage(), skills.values().stream().sorted((o1, o2) -> {
|
||||
if (o1.getIntentId().equals("get-status")) {
|
||||
return -1;
|
||||
}
|
||||
if (o2.getIntentId().equals("get-status")) {
|
||||
return 1;
|
||||
}
|
||||
return o1.getIntentId().compareTo(o2.getIntentId());
|
||||
}).collect(Collectors.toList()), getNameSamples(), this.tokenizerId);
|
||||
this.intentTrainer = intentTrainer;
|
||||
currentLocale = locale;
|
||||
} catch (Exception e) {
|
||||
|
@ -223,8 +218,8 @@ public class OpenNLPInterpreter implements HumanLanguageInterpreter {
|
|||
reply.setHint(intentInterpretation.getHint());
|
||||
}
|
||||
if (intentInterpretation.getMatchedItems() != null) {
|
||||
reply.setMatchedItems(intentInterpretation.getMatchedItems().stream().map(i -> i.getName())
|
||||
.collect(Collectors.toList()).toArray(new String[0]));
|
||||
reply.setMatchedItems(
|
||||
intentInterpretation.getMatchedItems().stream().map(Item::getName).toArray(String[]::new));
|
||||
}
|
||||
if (intentInterpretation.getCard() != null) {
|
||||
reply.setCard(intentInterpretation.getCard());
|
||||
|
|
|
@ -71,13 +71,12 @@ public class SemanticsItemResolver implements ItemResolver {
|
|||
if (location != null) {
|
||||
items = semanticsService.getItemsInLocation(location, currentLocale).stream();
|
||||
} else {
|
||||
items = new HashSet<Item>(itemRegistry.getAll()).stream();
|
||||
items = new HashSet<>(itemRegistry.getAll()).stream();
|
||||
}
|
||||
|
||||
if (object != null) {
|
||||
List<Class<? extends Tag>> semanticTagTypes = semanticsService.getByLabelOrSynonym(object, currentLocale);
|
||||
if (!semanticTagTypes.isEmpty()
|
||||
&& semanticTagTypes.stream().noneMatch(t -> Location.class.isAssignableFrom(t))) {
|
||||
if (!semanticTagTypes.isEmpty() && semanticTagTypes.stream().noneMatch(Location.class::isAssignableFrom)) {
|
||||
Predicate<Item> tagsPredicate = null;
|
||||
for (Class<? extends Tag> tag : semanticTagTypes) {
|
||||
Predicate<Item> tagPredicate = Property.class.isAssignableFrom(tag)
|
||||
|
@ -102,14 +101,14 @@ public class SemanticsItemResolver implements ItemResolver {
|
|||
throw new UnsupportedLanguageException(currentLocale);
|
||||
}
|
||||
|
||||
Map<Item, Set<ItemNamedAttribute>> attributes = new HashMap<Item, Set<ItemNamedAttribute>>();
|
||||
Map<Item, Set<ItemNamedAttribute>> attributes = new HashMap<>();
|
||||
|
||||
for (Item item : itemRegistry.getAll()) {
|
||||
Class<? extends Tag> semanticType = SemanticTags.getSemanticType(item);
|
||||
if (semanticType != null) {
|
||||
Set<ItemNamedAttribute> itemAttributes = new HashSet<ItemNamedAttribute>();
|
||||
Set<ItemNamedAttribute> itemAttributes = new HashSet<>();
|
||||
|
||||
attributes.put(item, new HashSet<ItemNamedAttribute>());
|
||||
attributes.put(item, new HashSet<>());
|
||||
String attributeType = (Location.class.isAssignableFrom(semanticType)) ? "location" : "object";
|
||||
|
||||
// Add the item's label
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.openhab.ui.habot.nlp.Intent;
|
|||
import org.openhab.ui.habot.nlp.IntentInterpretation;
|
||||
import org.openhab.ui.habot.nlp.ItemResolver;
|
||||
import org.openhab.ui.habot.nlp.Skill;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.service.component.annotations.Activate;
|
||||
import org.osgi.service.component.annotations.Reference;
|
||||
|
||||
|
@ -134,9 +133,7 @@ public class HistoryLastChangesSkill extends AbstractItemIntentInterpreter {
|
|||
final String pattern = stateDescription.getPattern();
|
||||
if (pattern != null) {
|
||||
try {
|
||||
String transformedState = TransformationHelper.transform(
|
||||
FrameworkUtil.getBundle(HistoryLastChangesSkill.class).getBundleContext(), pattern,
|
||||
state.toString());
|
||||
String transformedState = TransformationHelper.transform(pattern, state.toString());
|
||||
if (transformedState != null && transformedState.equals(state.toString())) {
|
||||
return state.format(pattern);
|
||||
} else {
|
||||
|
|
|
@ -85,10 +85,10 @@ public class WebPushNotificationAction implements ActionService {
|
|||
public static void sendHABotNotificationExt(String title, String message, String cardUID, List<Object> tags) {
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
HashMap<String, Object> payload = new HashMap<String, Object>();
|
||||
HashMap<String, Object> payload = new HashMap<>();
|
||||
payload.put("title", title);
|
||||
payload.put("body", message);
|
||||
HashMap<String, Object> data = new HashMap<String, Object>();
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
if (cardUID != null) {
|
||||
data.put("cardUID", cardUID);
|
||||
}
|
||||
|
|
|
@ -71,10 +71,10 @@ public class WebPushNotificationActionHandler extends BaseModuleHandler<Action>
|
|||
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
HashMap<String, Object> payload = new HashMap<String, Object>();
|
||||
HashMap<String, Object> payload = new HashMap<>();
|
||||
payload.put("title", (title != null) ? title : "HABot");
|
||||
payload.put("body", body);
|
||||
HashMap<String, Object> data = new HashMap<String, Object>();
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
if (cardUID != null) {
|
||||
data.put("cardUID", cardUID);
|
||||
}
|
||||
|
|
|
@ -193,9 +193,7 @@ public class NotificationService {
|
|||
generateVAPIDKeyPair();
|
||||
} catch (InvalidAlgorithmParameterException | NoSuchProviderException | NoSuchAlgorithmException
|
||||
| IOException e1) {
|
||||
RuntimeException ex = new RuntimeException("Cannot get the VAPID keypair for push notifications");
|
||||
ex.initCause(e1);
|
||||
throw ex;
|
||||
throw new RuntimeException("Cannot get the VAPID keypair for push notifications", e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public class PushService {
|
|||
byte[] salt = encrypted.getSalt();
|
||||
|
||||
Invocation.Builder invocationBuilder = ClientBuilder.newClient().target(notification.getEndpoint()).request();
|
||||
MultivaluedMap<String, Object> headers = new MultivaluedHashMap<String, Object>();
|
||||
MultivaluedMap<String, Object> headers = new MultivaluedHashMap<>();
|
||||
headers.add("TTL", String.valueOf(notification.getTTL()));
|
||||
|
||||
if (notification.hasPayload()) {
|
||||
|
|
|
@ -35,7 +35,7 @@ public class Subscription implements Identifiable<Keys> {
|
|||
this.keys = keys;
|
||||
}
|
||||
|
||||
public class Keys {
|
||||
public static class Keys {
|
||||
public final String p256dh;
|
||||
|
||||
public final String auth;
|
||||
|
|
|
@ -170,8 +170,8 @@ public class HABotResource implements RESTResource {
|
|||
|
||||
itemResolver.setLocale(locale);
|
||||
Map<String, Set<ItemNamedAttribute>> attributesByItemName = new HashMap<>();
|
||||
itemResolver.getAllItemNamedAttributes().entrySet().stream()
|
||||
.forEach(entry -> attributesByItemName.put(entry.getKey().getName(), entry.getValue()));
|
||||
itemResolver.getAllItemNamedAttributes()
|
||||
.forEach((key, value) -> attributesByItemName.put(key.getName(), value));
|
||||
|
||||
return Response.ok(attributesByItemName).build();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
package org.openhab.ui.habot.test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
@ -39,7 +38,7 @@ public class AbstractTrainerTest {
|
|||
protected IntentTrainer trainer = createUninitializedTrainer();
|
||||
protected List<Skill> skills = new ArrayList<>();
|
||||
|
||||
public class Skills {
|
||||
public static class Skills {
|
||||
public static final String GET_STATUS = "get-status";
|
||||
public static final String ACTIVATE_OBJECT = "activate-object";
|
||||
public static final String DEACTIVATE_OBJECT = "deactivate-object";
|
||||
|
@ -76,7 +75,7 @@ public class AbstractTrainerTest {
|
|||
return trainerMock;
|
||||
}
|
||||
|
||||
public class MockSkill implements Skill {
|
||||
public static class MockSkill implements Skill {
|
||||
|
||||
private String intent;
|
||||
|
||||
|
@ -103,9 +102,9 @@ public class AbstractTrainerTest {
|
|||
protected Intent interpret(String query) {
|
||||
System.out.println("----");
|
||||
System.out.println("\"" + query + "\"");
|
||||
System.out.println(new TreeMap<>(trainer.getScoreMap(query)).descendingMap().toString());
|
||||
System.out.println(new TreeMap<>(trainer.getScoreMap(query)).descendingMap());
|
||||
Intent intent = trainer.interpret(query);
|
||||
System.out.println(intent.toString());
|
||||
System.out.println(intent);
|
||||
return intent;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class CommunityWidgetGalleryProvider implements GalleryWidgetProvider {
|
|||
|
||||
@Override
|
||||
public Stream<GalleryWidgetsListItem> getGalleryList() throws Exception {
|
||||
List<DiscourseGalleryResponse> pages = new ArrayList<DiscourseGalleryResponse>();
|
||||
List<DiscourseGalleryResponse> pages = new ArrayList<>();
|
||||
|
||||
URL url = new URL(COMMUNITY_GALLERY_URL);
|
||||
int pageNb = 1;
|
||||
|
@ -71,7 +71,7 @@ public class CommunityWidgetGalleryProvider implements GalleryWidgetProvider {
|
|||
}
|
||||
}
|
||||
|
||||
return pages.stream().flatMap(p -> Stream.of(p.topic_list.topics)).map(t -> convertTopicToWidgetsListItem(t));
|
||||
return pages.stream().flatMap(p -> Stream.of(p.topic_list.topics)).map(this::convertTopicToWidgetsListItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,7 +118,7 @@ public class CommunityWidgetGalleryProvider implements GalleryWidgetProvider {
|
|||
widget.contents = new String(widgetDownload.getInputStream().readAllBytes(),
|
||||
StandardCharsets.UTF_8);
|
||||
String cDisp = widgetDownload.getHeaderField("Content-Disposition");
|
||||
if (cDisp != null && cDisp.indexOf("=") != -1 && cDisp.indexOf(".widget.json") != -1) {
|
||||
if (cDisp != null && cDisp.contains("=") && cDisp.contains(".widget.json")) {
|
||||
widget.id = cDisp.split("=")[1].replaceAll("\"", "").replaceAll("]", "")
|
||||
.replaceAll(".widget.json", "");
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class CommunityWidgetGalleryProvider implements GalleryWidgetProvider {
|
|||
/**
|
||||
* Transforms a Discourse topic to a {@link GalleryWidgetsListItem}
|
||||
*
|
||||
* @param topic the topic
|
||||
* @param t the topic
|
||||
* @return the list item
|
||||
*/
|
||||
private GalleryWidgetsListItem convertTopicToWidgetsListItem(Object t) {
|
||||
|
|
|
@ -24,19 +24,19 @@ public class DiscourseGalleryResponse {
|
|||
public DiscourseUser[] users;
|
||||
public DiscourseTopicList topic_list;
|
||||
|
||||
public class DiscourseUser {
|
||||
public static class DiscourseUser {
|
||||
public Integer id;
|
||||
public String username;
|
||||
public String avatar_template;
|
||||
}
|
||||
|
||||
public class DiscourseTopicList {
|
||||
public static class DiscourseTopicList {
|
||||
public String more_topics_url;
|
||||
public Integer per_page;
|
||||
public DiscourseTopic[] topics;
|
||||
}
|
||||
|
||||
public class DiscourseTopic {
|
||||
public static class DiscourseTopic {
|
||||
public Integer id;
|
||||
public String title;
|
||||
public String slug;
|
||||
|
|
|
@ -36,13 +36,13 @@ public class DiscourseTopicResponse {
|
|||
|
||||
public DiscourseTopicDetails details;
|
||||
|
||||
public class DiscoursePostAuthor {
|
||||
public static class DiscoursePostAuthor {
|
||||
public Integer id;
|
||||
public String username;
|
||||
public String avatar_template;
|
||||
}
|
||||
|
||||
public class DiscoursePostLink {
|
||||
public static class DiscoursePostLink {
|
||||
public String url;
|
||||
public Boolean internal;
|
||||
public Integer clicks;
|
||||
|
|
1
pom.xml
1
pom.xml
|
@ -419,6 +419,7 @@ Import-Package: \\
|
|||
<configuration>
|
||||
<checkstyleProperties>${basedirRoot}/tools/static-code-analysis/checkstyle/ruleset.properties</checkstyleProperties>
|
||||
<checkstyleFilter>${basedirRoot}/tools/static-code-analysis/checkstyle/suppressions.xml</checkstyleFilter>
|
||||
<spotbugsExclude>${basedirRoot}/tools/static-code-analysis/spotbugs/suppressions.xml</spotbugsExclude>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
|
|
@ -26,4 +26,8 @@
|
|||
<Match>
|
||||
<Bug pattern="SLF4J_SIGN_ONLY_FORMAT"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<!-- see https://github.com/spotbugs/spotbugs/issues/1992 -->
|
||||
<Bug pattern="SA_LOCAL_SELF_COMPARISON"/>
|
||||
</Match>
|
||||
</FindBugsFilter>
|
||||
|
|
Loading…
Reference in New Issue