Skip to content

Commit c6fc9d6

Browse files
committed
Apply Spotless
1 parent da2c419 commit c6fc9d6

File tree

16 files changed

+309
-233
lines changed

16 files changed

+309
-233
lines changed

agent/src/main/java/org/openremote/agent/custom/CustomAgent.java

+41-40
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/*
22
* Copyright 2017, OpenRemote Inc.
33
*
4-
* See the CONTRIBUTORS.txt file in the distribution for a
5-
* full listing of individual contributors.
6-
*
74
* This program is free software: you can redistribute it and/or modify
85
* it under the terms of the GNU Affero General Public License as
96
* published by the Free Software Foundation, either version 3 of the
@@ -15,10 +12,14 @@
1512
* GNU Affero General Public License for more details.
1613
*
1714
* You should have received a copy of the GNU Affero General Public License
18-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*
17+
* SPDX-License-Identifier: AGPL-3.0-or-later
1918
*/
2019
package org.openremote.agent.custom;
2120

21+
import java.util.Optional;
22+
2223
import org.openremote.model.asset.Asset;
2324
import org.openremote.model.asset.agent.Agent;
2425
import org.openremote.model.asset.agent.AgentDescriptor;
@@ -27,57 +28,57 @@
2728
import org.openremote.model.value.ValueDescriptor;
2829

2930
import jakarta.persistence.Entity;
30-
import java.util.Optional;
3131

3232
/**
33-
* This is an example of a custom {@link Agent} type; this must be registered via an
34-
* {@link org.openremote.model.AssetModelProvider} and must conform to the same requirements as custom {@link Asset}s and
35-
* in addition the following requirements:
33+
* This is an example of a custom {@link Agent} type; this must be registered via an {@link
34+
* org.openremote.model.AssetModelProvider} and must conform to the same requirements as custom
35+
* {@link Asset}s and in addition the following requirements:
3636
*
3737
* <ul>
38-
* <li>Optionally add a custom {@link org.openremote.model.asset.agent.AgentLink} (the {@link Class#getSimpleName} must
39-
* be unique compared to all other registered {@link org.openremote.model.asset.agent.AgentLink}s)
40-
* <li>Must define a {@link org.openremote.model.asset.agent.Protocol} implementation that corresponds to this {@link Agent}
41-
* <li>Must have a public static final {@link org.openremote.model.asset.agent.AgentDescriptor} rather than an
42-
* {@link org.openremote.model.asset.AssetDescriptor}
38+
* <li>Optionally add a custom {@link org.openremote.model.asset.agent.AgentLink} (the {@link
39+
* Class#getSimpleName} must be unique compared to all other registered {@link
40+
* org.openremote.model.asset.agent.AgentLink}s)
41+
* <li>Must define a {@link org.openremote.model.asset.agent.Protocol} implementation that
42+
* corresponds to this {@link Agent}
43+
* <li>Must have a public static final {@link org.openremote.model.asset.agent.AgentDescriptor}
44+
* rather than an {@link org.openremote.model.asset.AssetDescriptor}
4345
* </ul>
4446
*/
4547
@Entity
4648
public class CustomAgent extends Agent<CustomAgent, CustomProtocol, DefaultAgentLink> {
4749

48-
public enum Option {
49-
ONE,
50-
TWO,
51-
THREE
52-
};
50+
public enum Option {
51+
ONE,
52+
TWO,
53+
THREE
54+
};
5355

54-
public static final ValueDescriptor<Option> OPTION_VALUE_DESCRIPTOR = new ValueDescriptor<>("customAgentOption", Option.class);
56+
public static final ValueDescriptor<Option> OPTION_VALUE_DESCRIPTOR =
57+
new ValueDescriptor<>("customAgentOption", Option.class);
5558

56-
public static final AttributeDescriptor<Option> OPTION_ATTRIBUTE_DESCRIPTOR = new AttributeDescriptor<>("option", OPTION_VALUE_DESCRIPTOR);
59+
public static final AttributeDescriptor<Option> OPTION_ATTRIBUTE_DESCRIPTOR =
60+
new AttributeDescriptor<>("option", OPTION_VALUE_DESCRIPTOR);
5761

58-
public static final AgentDescriptor<CustomAgent, CustomProtocol, DefaultAgentLink> DESCRIPTOR = new AgentDescriptor<>(
59-
CustomAgent.class, CustomProtocol.class, DefaultAgentLink.class
60-
);
62+
public static final AgentDescriptor<CustomAgent, CustomProtocol, DefaultAgentLink> DESCRIPTOR =
63+
new AgentDescriptor<>(CustomAgent.class, CustomProtocol.class, DefaultAgentLink.class);
6164

62-
protected CustomAgent() {
63-
}
65+
protected CustomAgent() {}
6466

65-
public CustomAgent(String name) {
66-
super(name);
67-
}
67+
public CustomAgent(String name) {
68+
super(name);
69+
}
6870

69-
@Override
70-
public CustomProtocol getProtocolInstance() {
71-
return new CustomProtocol(this);
72-
}
71+
@Override
72+
public CustomProtocol getProtocolInstance() {
73+
return new CustomProtocol(this);
74+
}
7375

74-
public Optional<Option> getOption() {
75-
return getAttributes().getValue(OPTION_ATTRIBUTE_DESCRIPTOR);
76-
}
76+
public Optional<Option> getOption() {
77+
return getAttributes().getValue(OPTION_ATTRIBUTE_DESCRIPTOR);
78+
}
7779

78-
public CustomAgent setOption(Option value) {
79-
getAttributes().getOrCreate(OPTION_ATTRIBUTE_DESCRIPTOR).setValue(value);
80-
return this;
81-
}
80+
public CustomAgent setOption(Option value) {
81+
getAttributes().getOrCreate(OPTION_ATTRIBUTE_DESCRIPTOR).setValue(value);
82+
return this;
83+
}
8284
}
83-
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/*
22
* Copyright 2021, OpenRemote Inc.
33
*
4-
* See the CONTRIBUTORS.txt file in the distribution for a
5-
* full listing of individual contributors.
6-
*
74
* This program is free software: you can redistribute it and/or modify
85
* it under the terms of the GNU Affero General Public License as
96
* published by the Free Software Foundation, either version 3 of the
@@ -15,17 +12,18 @@
1512
* GNU Affero General Public License for more details.
1613
*
1714
* You should have received a copy of the GNU Affero General Public License
18-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*
17+
* SPDX-License-Identifier: AGPL-3.0-or-later
1918
*/
20-
2119
package org.openremote.agent.custom;
2220

2321
import org.openremote.model.AssetModelProvider;
2422

2523
public class CustomAgentModelProvider implements AssetModelProvider {
2624

27-
@Override
28-
public boolean useAutoScan() {
29-
return true;
30-
}
25+
@Override
26+
public boolean useAutoScan() {
27+
return true;
28+
}
3129
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/*
22
* Copyright 2017, OpenRemote Inc.
33
*
4-
* See the CONTRIBUTORS.txt file in the distribution for a
5-
* full listing of individual contributors.
6-
*
74
* This program is free software: you can redistribute it and/or modify
85
* it under the terms of the GNU Affero General Public License as
96
* published by the Free Software Foundation, either version 3 of the
@@ -15,68 +12,66 @@
1512
* GNU Affero General Public License for more details.
1613
*
1714
* You should have received a copy of the GNU Affero General Public License
18-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*
17+
* SPDX-License-Identifier: AGPL-3.0-or-later
1918
*/
2019
package org.openremote.agent.custom;
2120

21+
import static org.openremote.model.syslog.SyslogCategory.PROTOCOL;
22+
23+
import java.util.logging.Logger;
24+
2225
import org.openremote.agent.protocol.AbstractProtocol;
2326
import org.openremote.model.Container;
2427
import org.openremote.model.asset.agent.DefaultAgentLink;
2528
import org.openremote.model.attribute.Attribute;
2629
import org.openremote.model.attribute.AttributeEvent;
2730
import org.openremote.model.syslog.SyslogCategory;
2831

29-
import java.util.logging.Logger;
30-
31-
import static org.openremote.model.syslog.SyslogCategory.PROTOCOL;
32-
3332
/**
34-
* A custom protocol that is used by the {@link CustomAgent}; there is a one-to-one mapping between an {@link
35-
* CustomAgent} {@link org.openremote.model.asset.Asset} and its' {@link org.openremote.model.asset.agent.Protocol}.
36-
* This example does nothing useful but is intended to show where protocol classes should be created.
33+
* A custom protocol that is used by the {@link CustomAgent}; there is a one-to-one mapping between
34+
* an {@link CustomAgent} {@link org.openremote.model.asset.Asset} and its' {@link
35+
* org.openremote.model.asset.agent.Protocol}. This example does nothing useful but is intended to
36+
* show where protocol classes should be created.
3737
*/
3838
public class CustomProtocol extends AbstractProtocol<CustomAgent, DefaultAgentLink> {
3939

40-
public static final String PROTOCOL_DISPLAY_NAME = "Custom";
41-
private static final Logger LOG = SyslogCategory.getLogger(PROTOCOL, CustomProtocol.class);
42-
protected boolean running;
43-
44-
public CustomProtocol(CustomAgent agent) {
45-
super(agent);
46-
}
47-
48-
@Override
49-
protected void doStart(Container container) throws Exception {
50-
running = true;
51-
}
52-
53-
@Override
54-
protected void doStop(Container container) throws Exception {
55-
56-
}
40+
public static final String PROTOCOL_DISPLAY_NAME = "Custom";
41+
private static final Logger LOG = SyslogCategory.getLogger(PROTOCOL, CustomProtocol.class);
42+
protected boolean running;
5743

58-
@Override
59-
protected void doLinkAttribute(String assetId, Attribute<?> attribute, DefaultAgentLink agentLink) throws RuntimeException {
44+
public CustomProtocol(CustomAgent agent) {
45+
super(agent);
46+
}
6047

61-
}
48+
@Override
49+
protected void doStart(Container container) throws Exception {
50+
running = true;
51+
}
6252

63-
@Override
64-
protected void doUnlinkAttribute(String assetId, Attribute<?> attribute, DefaultAgentLink agentLink) {
53+
@Override
54+
protected void doStop(Container container) throws Exception {}
6555

66-
}
56+
@Override
57+
protected void doLinkAttribute(String assetId, Attribute<?> attribute, DefaultAgentLink agentLink)
58+
throws RuntimeException {}
6759

68-
@Override
69-
protected void doLinkedAttributeWrite(DefaultAgentLink agentLink, AttributeEvent event, Object processedValue) {
60+
@Override
61+
protected void doUnlinkAttribute(
62+
String assetId, Attribute<?> attribute, DefaultAgentLink agentLink) {}
7063

71-
}
64+
@Override
65+
protected void doLinkedAttributeWrite(
66+
DefaultAgentLink agentLink, AttributeEvent event, Object processedValue) {}
7267

73-
@Override
74-
public String getProtocolName() {
75-
return PROTOCOL_DISPLAY_NAME;
76-
}
68+
@Override
69+
public String getProtocolName() {
70+
return PROTOCOL_DISPLAY_NAME;
71+
}
7772

78-
@Override
79-
public String getProtocolInstanceUri() {
80-
return "custom://" + agent.getOption();
81-
}
73+
@Override
74+
public String getProtocolInstanceUri() {
75+
return "custom://" + agent.getOption();
76+
}
8277
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/*
22
* Copyright 2021, OpenRemote Inc.
33
*
4-
* See the CONTRIBUTORS.txt file in the distribution for a
5-
* full listing of individual contributors.
6-
*
74
* This program is free software: you can redistribute it and/or modify
85
* it under the terms of the GNU Affero General Public License as
96
* published by the Free Software Foundation, either version 3 of the
@@ -15,26 +12,22 @@
1512
* GNU Affero General Public License for more details.
1613
*
1714
* You should have received a copy of the GNU Affero General Public License
18-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*
17+
* SPDX-License-Identifier: AGPL-3.0-or-later
1918
*/
2019
package org.openremote.manager.custom;
2120

2221
import org.openremote.model.Container;
2322
import org.openremote.model.ContainerService;
2423

2524
public class CustomService implements ContainerService {
26-
@Override
27-
public void init(Container container) throws Exception {
28-
29-
}
30-
31-
@Override
32-
public void start(Container container) throws Exception {
33-
34-
}
25+
@Override
26+
public void init(Container container) throws Exception {}
3527

36-
@Override
37-
public void stop(Container container) throws Exception {
28+
@Override
29+
public void start(Container container) throws Exception {}
3830

39-
}
31+
@Override
32+
public void stop(Container container) throws Exception {}
4033
}

0 commit comments

Comments
 (0)