Skip to content

Commit

Permalink
Cleanup asset hydration constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
richturner committed Feb 24, 2021
1 parent 6f559bd commit 40c2772
Show file tree
Hide file tree
Showing 56 changed files with 66 additions and 106 deletions.
Expand Up @@ -35,7 +35,7 @@ public class ArtnetAgent extends IoAgent<ArtnetAgent, ArtnetProtocol, AgentLink.
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ArtnetAgent() {
protected ArtnetAgent() {
}

public ArtnetAgent(String name) {
Expand Down
Expand Up @@ -31,8 +31,7 @@ public class ArtnetLightAsset extends LightAsset {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ArtnetLightAsset() {
this(null);
protected ArtnetLightAsset() {
}

protected ArtnetLightAsset(String name) {
Expand Down
Expand Up @@ -104,8 +104,7 @@ public ControllerAgentLink setCommandsMap(Map<String, List<String>> commandsMap)
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ControllerAgent() {
this(null);
protected ControllerAgent() {
}

public ControllerAgent(String name) {
Expand Down
Expand Up @@ -45,8 +45,7 @@ public class ClientEventAgent extends Agent<ClientEventAgent, ClientEventProtoco
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ClientEventAgent() {
this(null);
protected ClientEventAgent() {
}


Expand Down
Expand Up @@ -140,11 +140,9 @@ public HttpClientAgentLink setPollingAttribute(String pollingAttribute) {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
HttpClientAgent() {
this(null);
protected HttpClientAgent() {
}


public HttpClientAgent(String name) {
super(name);
}
Expand Down
Expand Up @@ -98,8 +98,7 @@ public KNXAgentLink setStatusGroupAddress(String statusGroupAddress) {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
KNXAgent() {
this(null);
protected KNXAgent() {
}

public KNXAgent(String name) {
Expand Down
Expand Up @@ -71,8 +71,7 @@ public MacroAgentLink setActionIndex(Integer actionIndex) {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
MacroAgent() {
this(null);
protected MacroAgent() {
}

public MacroAgent(String name) {
Expand Down
Expand Up @@ -35,7 +35,7 @@ public class SerialAgent extends IoAgent<SerialAgent, SerialClientProtocol, Agen
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
SerialAgent() {
protected SerialAgent() {
}

public SerialAgent(String name) {
Expand Down
Expand Up @@ -61,8 +61,7 @@ public SimulatorAgentLink setSimulatorReplayData(SimulatorReplayDatapoint[] simu
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
SimulatorAgent() {
this(null);
protected SimulatorAgent() {
}

public SimulatorAgent(String name) {
Expand Down
Expand Up @@ -35,7 +35,7 @@ public class TcpClientAgent extends IoAgent<TcpClientAgent, TcpClientProtocol, A
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
TcpClientAgent() {
protected TcpClientAgent() {
}

public TcpClientAgent(String name) {
Expand Down
Expand Up @@ -69,8 +69,7 @@ public TimerAgentLink setTimerValue(TimerValue timerValue) {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
TimerAgent() {
this(null);
protected TimerAgent() {
}

public TimerAgent(String name) {
Expand Down
Expand Up @@ -43,8 +43,7 @@ public class TradfriAgent extends Agent<TradfriAgent, TradfriProtocol, AgentLink
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
TradfriAgent() {
this(null);
protected TradfriAgent() {
}

public TradfriAgent(String name) {
Expand Down
Expand Up @@ -20,8 +20,7 @@ public class TradfriLightAsset extends LightAsset implements TradfriAsset {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
TradfriLightAsset() {
this(null);
protected TradfriLightAsset() {
}

public TradfriLightAsset(String name) {
Expand Down
Expand Up @@ -21,8 +21,7 @@ public class TradfriPlugAsset extends PlugAsset implements TradfriAsset {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
TradfriPlugAsset() {
this(null);
protected TradfriPlugAsset() {
}

public TradfriPlugAsset(String name) {
Expand Down
Expand Up @@ -35,7 +35,7 @@ public class UdpClientAgent extends IoAgent<UdpClientAgent, UdpClientProtocol, A
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
UdpClientAgent() {
protected UdpClientAgent() {
}

public UdpClientAgent(String name) {
Expand Down
Expand Up @@ -36,7 +36,7 @@ public class VelbusSerialAgent extends VelbusAgent<VelbusSerialAgent, VelbusSeri
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
VelbusSerialAgent() {
protected VelbusSerialAgent() {
}

public VelbusSerialAgent(String name) {
Expand Down
Expand Up @@ -37,7 +37,7 @@ public class VelbusTcpAgent extends VelbusAgent<VelbusTcpAgent, VelbusTcpProtoco
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
VelbusTcpAgent() {
protected VelbusTcpAgent() {
}

public VelbusTcpAgent(String name) {
Expand Down
Expand Up @@ -80,7 +80,7 @@ public WebsocketClientAgentLink setWebsocketSubscriptions(WebsocketSubscription[
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
WebsocketClientAgent() {
protected WebsocketClientAgent() {
}

public WebsocketClientAgent(String name) {
Expand Down
Expand Up @@ -65,8 +65,7 @@ public Optional<String> getDeviceValue() {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ZWAgent() {
this(null);
protected ZWAgent() {
}

public ZWAgent(String name) {
Expand Down
2 changes: 2 additions & 0 deletions deployment/manager/shared/locales/en/or.json
Expand Up @@ -393,5 +393,7 @@
"repetitionEnds": "Repetition ends",
"repeatOccurrenceEvery": "Repeat occurrence every",
"daysOfTheWeek": "days of the week",
"dismiss": "dismiss",
"createAssetFailed": "Failed to create asset",
"logCategory": {}
}
13 changes: 4 additions & 9 deletions model/src/main/java/org/openremote/model/asset/Asset.java
Expand Up @@ -40,14 +40,8 @@

import javax.persistence.*;
import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.Optional;
import javax.validation.constraints.*;
import java.util.*;

import static javax.persistence.DiscriminatorType.STRING;
import static org.openremote.model.Constants.PERSISTENCE_JSON_VALUE_TYPE;
Expand Down Expand Up @@ -364,7 +358,8 @@ public String getName() {
}


public T setName(String name) throws IllegalArgumentException {
public T setName(@NotNull String name) throws IllegalArgumentException {
Objects.requireNonNull(name);
this.name = name;
return (T) this;
}
Expand Down
Expand Up @@ -48,8 +48,7 @@ public class BuildingAsset extends CityAsset {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
BuildingAsset() {
this(null);
protected BuildingAsset() {
}

public BuildingAsset(String name) {
Expand Down
Expand Up @@ -40,8 +40,7 @@ public class CityAsset extends Asset<CityAsset> {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
CityAsset() {
this(null);
protected CityAsset() {
}

public CityAsset(String name) {
Expand Down
Expand Up @@ -43,8 +43,7 @@ public class ConsoleAsset extends Asset<ConsoleAsset> {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ConsoleAsset() {
this(null);
protected ConsoleAsset() {
}

public ConsoleAsset(String name) {
Expand Down
Expand Up @@ -42,8 +42,7 @@ public class DoorSensorAsset extends Asset<DoorSensorAsset> {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
DoorSensorAsset() {
this(null);
protected DoorSensorAsset() {
}

public DoorSensorAsset(String name) {
Expand Down
Expand Up @@ -60,8 +60,7 @@ public class ElectricVehicleAsset extends ElectricityBatteryAsset {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ElectricVehicleAsset() {
this(null);
protected ElectricVehicleAsset() {
}

public ElectricVehicleAsset(String name) {
Expand Down
Expand Up @@ -47,7 +47,7 @@ public class ElectricVehicleFleetGroupAsset extends GroupAsset {

public static final AssetDescriptor<ElectricVehicleFleetGroupAsset> DESCRIPTOR = new AssetDescriptor<>("car-multiple", "49B0D8", ElectricVehicleFleetGroupAsset.class);

ElectricVehicleFleetGroupAsset() {
protected ElectricVehicleFleetGroupAsset() {
}

public ElectricVehicleFleetGroupAsset(String name) {
Expand Down
Expand Up @@ -75,8 +75,7 @@ public abstract class ElectricityAsset<T extends ElectricityAsset<?>> extends As
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ElectricityAsset() {
this(null);
protected ElectricityAsset() {
}

public ElectricityAsset(String name) {
Expand Down
Expand Up @@ -37,7 +37,7 @@ public class ElectricityBatteryAsset extends ElectricityStorageAsset {

public static final AssetDescriptor<ElectricityBatteryAsset> DESCRIPTOR = new AssetDescriptor<>("battery-charging", "1B7C89", ElectricityBatteryAsset.class);

ElectricityBatteryAsset() {
protected ElectricityBatteryAsset() {
}

public ElectricityBatteryAsset(String name) {
Expand Down
Expand Up @@ -71,8 +71,7 @@ public enum ConnectorType {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ElectricityChargerAsset() {
this(null);
protected ElectricityChargerAsset() {
}

public ElectricityChargerAsset(String name) {
Expand Down
Expand Up @@ -50,8 +50,7 @@ public class ElectricityConsumerAsset extends ElectricityAsset<ElectricityConsum
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ElectricityConsumerAsset() {
this(null);
protected ElectricityConsumerAsset() {
}

public ElectricityConsumerAsset(String name) {
Expand Down
Expand Up @@ -46,7 +46,6 @@ public class ElectricityProducerAsset extends ElectricityAsset<ElectricityProduc
* For use by hydrators (i.e. JPA/Jackson)
*/
ElectricityProducerAsset() {
this(null);
}

public ElectricityProducerAsset(String name) {
Expand Down
Expand Up @@ -55,8 +55,7 @@ public enum PanelOrientation {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ElectricityProducerSolarAsset() {
this(null);
protected ElectricityProducerSolarAsset() {
}

public ElectricityProducerSolarAsset(String name) {
Expand Down
Expand Up @@ -43,7 +43,10 @@ public class ElectricityProducerWindAsset extends ElectricityProducerAsset {

public static final AssetDescriptor<ElectricityProducerWindAsset> DESCRIPTOR = new AssetDescriptor<>("wind-turbine", "4B87EA", ElectricityProducerWindAsset.class);

ElectricityProducerWindAsset() {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
protected ElectricityProducerWindAsset() {
}

public ElectricityProducerWindAsset(String name) {
Expand Down
Expand Up @@ -59,8 +59,7 @@ public abstract class ElectricityStorageAsset extends ElectricityAsset<Electrici
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ElectricityStorageAsset() {
this(null);
protected ElectricityStorageAsset() {
}

public ElectricityStorageAsset(String name) {
Expand Down
Expand Up @@ -57,8 +57,7 @@ public class ElectricitySupplierAsset extends ElectricityAsset<ElectricitySuppli
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
ElectricitySupplierAsset() {
this(null);
protected ElectricitySupplierAsset() {
}

public ElectricitySupplierAsset(String name) {
Expand Down
Expand Up @@ -63,8 +63,7 @@ public class EnvironmentSensorAsset extends Asset<EnvironmentSensorAsset> {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
EnvironmentSensorAsset() {
this(null);
protected EnvironmentSensorAsset() {
}

public EnvironmentSensorAsset(String name) {
Expand Down
Expand Up @@ -41,8 +41,7 @@ public class GatewayAsset extends Asset<GatewayAsset> {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
GatewayAsset() {
this(null);
protected GatewayAsset() {
}

public GatewayAsset(String name) {
Expand Down
Expand Up @@ -47,8 +47,7 @@ public class GroundwaterSensorAsset extends Asset<GroundwaterSensorAsset> {
/**
* For use by hydrators (i.e. JPA/Jackson)
*/
GroundwaterSensorAsset() {
this(null);
protected GroundwaterSensorAsset() {
}

public GroundwaterSensorAsset(String name) {
Expand Down

0 comments on commit 40c2772

Please sign in to comment.