mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[lametrictime] Move external library to internal code (#14425)
Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
parent
1d34515c34
commit
ce41708622
@ -14,11 +14,6 @@ https://github.com/openhab/openhab-addons
|
|||||||
|
|
||||||
== Third-party Content
|
== Third-party Content
|
||||||
|
|
||||||
The sources of liblametrictime-java are included in src/3rdparty/java and have been slightly adapted.
|
This binding includes classes from Jersey in the src/3rdparty/java folder.
|
||||||
* License: Apache 2.0 License
|
|
||||||
* Project: https://github.com/syphr42/liblametrictime-java
|
|
||||||
|
|
||||||
|
|
||||||
This binding includes a class from Jersey in the src/3rdparty/java folder.
|
|
||||||
* License: CDDL License
|
* License: CDDL License
|
||||||
* Project: https://eclipse-ee4j.github.io/jersey/
|
* Project: https://eclipse-ee4j.github.io/jersey/
|
@ -35,18 +35,6 @@
|
|||||||
</sources>
|
</sources>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
|
||||||
<id>add-test-source</id>
|
|
||||||
<phase>generate-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>add-test-source</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<sources>
|
|
||||||
<source>src/3rdparty/test</source>
|
|
||||||
</sources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -1,162 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.cloud.CloudConfiguration;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.LocalConfiguration;
|
|
||||||
|
|
||||||
public class Configuration
|
|
||||||
{
|
|
||||||
private String deviceHost;
|
|
||||||
private String deviceApiKey;
|
|
||||||
|
|
||||||
private boolean ignoreDeviceCertificateValidation = true;
|
|
||||||
private boolean ignoreDeviceHostnameValidation = true;
|
|
||||||
|
|
||||||
private boolean logging = false;
|
|
||||||
private String logLevel = "INFO";
|
|
||||||
private int logMax = 104857600; // 100kb
|
|
||||||
|
|
||||||
public String getDeviceHost()
|
|
||||||
{
|
|
||||||
return deviceHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDeviceHost(String deviceHost)
|
|
||||||
{
|
|
||||||
this.deviceHost = deviceHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Configuration withDeviceHost(String deviceHost)
|
|
||||||
{
|
|
||||||
this.deviceHost = deviceHost;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDeviceApiKey()
|
|
||||||
{
|
|
||||||
return deviceApiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDeviceApiKey(String deviceApiKey)
|
|
||||||
{
|
|
||||||
this.deviceApiKey = deviceApiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Configuration withDeviceApiKey(String deviceApiKey)
|
|
||||||
{
|
|
||||||
this.deviceApiKey = deviceApiKey;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIgnoreDeviceCertificateValidation()
|
|
||||||
{
|
|
||||||
return ignoreDeviceCertificateValidation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIgnoreDeviceCertificateValidation(boolean ignoreDeviceCertificateValidation)
|
|
||||||
{
|
|
||||||
this.ignoreDeviceCertificateValidation = ignoreDeviceCertificateValidation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Configuration withIgnoreDeviceCertificateValidation(boolean ignoreDeviceCertificateValidation)
|
|
||||||
{
|
|
||||||
this.ignoreDeviceCertificateValidation = ignoreDeviceCertificateValidation;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIgnoreDeviceHostnameValidation()
|
|
||||||
{
|
|
||||||
return ignoreDeviceHostnameValidation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIgnoreDeviceHostnameValidation(boolean ignoreDeviceHostnameValidation)
|
|
||||||
{
|
|
||||||
this.ignoreDeviceHostnameValidation = ignoreDeviceHostnameValidation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Configuration withIgnoreDeviceHostnameValidation(boolean ignoreDeviceHostnameValidation)
|
|
||||||
{
|
|
||||||
this.ignoreDeviceHostnameValidation = ignoreDeviceHostnameValidation;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLogging()
|
|
||||||
{
|
|
||||||
return logging;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogging(boolean logging)
|
|
||||||
{
|
|
||||||
this.logging = logging;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Configuration withLogging(boolean logging)
|
|
||||||
{
|
|
||||||
this.logging = logging;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLogLevel()
|
|
||||||
{
|
|
||||||
return logLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogLevel(String logLevel)
|
|
||||||
{
|
|
||||||
this.logLevel = logLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Configuration withLogLevel(String logLevel)
|
|
||||||
{
|
|
||||||
this.logLevel = logLevel;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLogMax()
|
|
||||||
{
|
|
||||||
return logMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogMax(int logMax)
|
|
||||||
{
|
|
||||||
this.logMax = logMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Configuration withLogMax(int logMax)
|
|
||||||
{
|
|
||||||
this.logMax = logMax;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalConfiguration getLocalConfig()
|
|
||||||
{
|
|
||||||
return new LocalConfiguration().withHost(deviceHost)
|
|
||||||
.withApiKey(deviceApiKey)
|
|
||||||
.withIgnoreCertificateValidation(ignoreDeviceCertificateValidation)
|
|
||||||
.withIgnoreHostnameValidation(ignoreDeviceHostnameValidation)
|
|
||||||
.withLogging(logging)
|
|
||||||
.withLogLevel(logLevel)
|
|
||||||
.withLogMax(logMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloudConfiguration getCloudConfig()
|
|
||||||
{
|
|
||||||
return new CloudConfiguration().withLogging(logging)
|
|
||||||
.withLogLevel(logLevel)
|
|
||||||
.withLogMax(logMax);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.cloud;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
public class CloudConfiguration
|
|
||||||
{
|
|
||||||
private URI baseUri = URI.create("https://developer.lametric.com/api/v2");
|
|
||||||
|
|
||||||
private boolean logging = false;
|
|
||||||
private String logLevel = "INFO";
|
|
||||||
private int logMax = 104857600; // 100kb
|
|
||||||
|
|
||||||
public URI getBaseUri()
|
|
||||||
{
|
|
||||||
return baseUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBaseUri(URI baseUri)
|
|
||||||
{
|
|
||||||
this.baseUri = baseUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloudConfiguration withBaseUri(URI baseUri)
|
|
||||||
{
|
|
||||||
this.baseUri = baseUri;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLogging()
|
|
||||||
{
|
|
||||||
return logging;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogging(boolean logging)
|
|
||||||
{
|
|
||||||
this.logging = logging;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloudConfiguration withLogging(boolean logging)
|
|
||||||
{
|
|
||||||
this.logging = logging;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLogLevel()
|
|
||||||
{
|
|
||||||
return logLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogLevel(String logLevel)
|
|
||||||
{
|
|
||||||
this.logLevel = logLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloudConfiguration withLogLevel(String logLevel)
|
|
||||||
{
|
|
||||||
this.logLevel = logLevel;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLogMax()
|
|
||||||
{
|
|
||||||
return logMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogMax(int logMax)
|
|
||||||
{
|
|
||||||
this.logMax = logMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CloudConfiguration withLogMax(int logMax)
|
|
||||||
{
|
|
||||||
this.logMax = logMax;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.cloud;
|
|
||||||
|
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.cloud.impl.LaMetricTimeCloudImpl;
|
|
||||||
import org.openhab.binding.lametrictime.api.cloud.model.IconFilter;
|
|
||||||
import org.openhab.binding.lametrictime.api.cloud.model.Icons;
|
|
||||||
|
|
||||||
public interface LaMetricTimeCloud
|
|
||||||
{
|
|
||||||
public Icons getIcons();
|
|
||||||
|
|
||||||
public Icons getIcons(IconFilter filter);
|
|
||||||
|
|
||||||
public static LaMetricTimeCloud create(CloudConfiguration config)
|
|
||||||
{
|
|
||||||
return new LaMetricTimeCloudImpl(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LaMetricTimeCloud create(CloudConfiguration config, ClientBuilder clientBuilder)
|
|
||||||
{
|
|
||||||
return new LaMetricTimeCloudImpl(config, clientBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,139 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.cloud.model;
|
|
||||||
|
|
||||||
public class Icon
|
|
||||||
{
|
|
||||||
private Integer id;
|
|
||||||
private String title;
|
|
||||||
private String code;
|
|
||||||
private IconType type;
|
|
||||||
private String category;
|
|
||||||
private String url;
|
|
||||||
private Thumb thumb;
|
|
||||||
|
|
||||||
public Integer getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Icon withId(Integer id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle()
|
|
||||||
{
|
|
||||||
return title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTitle(String title)
|
|
||||||
{
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Icon withTitle(String title)
|
|
||||||
{
|
|
||||||
this.title = title;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCode()
|
|
||||||
{
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(String code)
|
|
||||||
{
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Icon withCode(String code)
|
|
||||||
{
|
|
||||||
this.code = code;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IconType getType()
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(IconType type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Icon withType(IconType type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCategory()
|
|
||||||
{
|
|
||||||
return category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCategory(String category)
|
|
||||||
{
|
|
||||||
this.category = category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Icon withCategory(String category)
|
|
||||||
{
|
|
||||||
this.category = category;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUrl()
|
|
||||||
{
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(String url)
|
|
||||||
{
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Icon withUrl(String url)
|
|
||||||
{
|
|
||||||
this.url = url;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Thumb getThumb()
|
|
||||||
{
|
|
||||||
return thumb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setThumb(Thumb thumb)
|
|
||||||
{
|
|
||||||
this.thumb = thumb;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Icon withThumb(Thumb thumb)
|
|
||||||
{
|
|
||||||
this.thumb = thumb;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.cloud.model;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
public enum IconField
|
|
||||||
{
|
|
||||||
@SerializedName("id")
|
|
||||||
ID,
|
|
||||||
@SerializedName("title")
|
|
||||||
TITLE,
|
|
||||||
@SerializedName("code")
|
|
||||||
CODE,
|
|
||||||
@SerializedName("type")
|
|
||||||
TYPE,
|
|
||||||
@SerializedName("url")
|
|
||||||
URL,
|
|
||||||
@SerializedName("thumb")
|
|
||||||
THUMB
|
|
||||||
}
|
|
@ -1,113 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.cloud.model;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class IconFilter
|
|
||||||
{
|
|
||||||
private Integer page;
|
|
||||||
private Integer pageSize;
|
|
||||||
private List<IconField> fields;
|
|
||||||
private IconOrder order;
|
|
||||||
|
|
||||||
public Integer getPage()
|
|
||||||
{
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPage(Integer page)
|
|
||||||
{
|
|
||||||
this.page = page;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IconFilter withPage(Integer page)
|
|
||||||
{
|
|
||||||
this.page = page;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPageSize()
|
|
||||||
{
|
|
||||||
return pageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageSize(Integer pageSize)
|
|
||||||
{
|
|
||||||
this.pageSize = pageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IconFilter withPageSize(Integer pageSize)
|
|
||||||
{
|
|
||||||
this.pageSize = pageSize;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<IconField> getFields()
|
|
||||||
{
|
|
||||||
return fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFieldsString()
|
|
||||||
{
|
|
||||||
if (fields == null || fields.isEmpty())
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append(fields.get(0).name().toLowerCase());
|
|
||||||
|
|
||||||
for (int i = 1; i < fields.size(); i++)
|
|
||||||
{
|
|
||||||
builder.append(',').append(fields.get(i).name().toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFields(List<IconField> fields)
|
|
||||||
{
|
|
||||||
this.fields = fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IconFilter withFields(List<IconField> fields)
|
|
||||||
{
|
|
||||||
this.fields = fields;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IconOrder getOrder()
|
|
||||||
{
|
|
||||||
return order;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOrderString()
|
|
||||||
{
|
|
||||||
return order == null ? null : order.name().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrder(IconOrder order)
|
|
||||||
{
|
|
||||||
this.order = order;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IconFilter withOrder(IconOrder order)
|
|
||||||
{
|
|
||||||
this.order = order;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.cloud.model;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
public enum IconOrder
|
|
||||||
{
|
|
||||||
@SerializedName("popular")
|
|
||||||
POPULAR,
|
|
||||||
@SerializedName("newest")
|
|
||||||
NEWEST,
|
|
||||||
@SerializedName("title")
|
|
||||||
TITLE
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.cloud.model;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
public enum IconType
|
|
||||||
{
|
|
||||||
@SerializedName("picture")
|
|
||||||
PICTURE,
|
|
||||||
@SerializedName("movie")
|
|
||||||
MOVIE
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.cloud.model;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Icons
|
|
||||||
{
|
|
||||||
private IconsMetadata meta;
|
|
||||||
private List<Icon> data = new ArrayList<Icon>();
|
|
||||||
|
|
||||||
public IconsMetadata getMeta()
|
|
||||||
{
|
|
||||||
return meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMeta(IconsMetadata meta)
|
|
||||||
{
|
|
||||||
this.meta = meta;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Icons withMeta(IconsMetadata meta)
|
|
||||||
{
|
|
||||||
this.meta = meta;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Icon> getData()
|
|
||||||
{
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(List<Icon> data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Icons withData(List<Icon> data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.cloud.model;
|
|
||||||
|
|
||||||
public class IconsMetadata
|
|
||||||
{
|
|
||||||
private Integer totalIconCount;
|
|
||||||
private Integer page;
|
|
||||||
private Integer pageSize;
|
|
||||||
private Integer pageCount;
|
|
||||||
|
|
||||||
public Integer getTotalIconCount()
|
|
||||||
{
|
|
||||||
return totalIconCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTotalIconCount(Integer totalIconCount)
|
|
||||||
{
|
|
||||||
this.totalIconCount = totalIconCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IconsMetadata withTotalIconCount(Integer totalIconCount)
|
|
||||||
{
|
|
||||||
this.totalIconCount = totalIconCount;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPage()
|
|
||||||
{
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPage(Integer page)
|
|
||||||
{
|
|
||||||
this.page = page;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IconsMetadata withPage(Integer page)
|
|
||||||
{
|
|
||||||
this.page = page;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPageSize()
|
|
||||||
{
|
|
||||||
return pageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageSize(Integer pageSize)
|
|
||||||
{
|
|
||||||
this.pageSize = pageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IconsMetadata withPageSize(Integer pageSize)
|
|
||||||
{
|
|
||||||
this.pageSize = pageSize;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPageCount()
|
|
||||||
{
|
|
||||||
return pageCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageCount(Integer pageCount)
|
|
||||||
{
|
|
||||||
this.pageCount = pageCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IconsMetadata withPageCount(Integer pageCount)
|
|
||||||
{
|
|
||||||
this.pageCount = pageCount;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,88 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.cloud.model;
|
|
||||||
|
|
||||||
public class Thumb
|
|
||||||
{
|
|
||||||
private String original;
|
|
||||||
private String small;
|
|
||||||
private String large;
|
|
||||||
private String xlarge;
|
|
||||||
|
|
||||||
public String getOriginal()
|
|
||||||
{
|
|
||||||
return original;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOriginal(String original)
|
|
||||||
{
|
|
||||||
this.original = original;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Thumb withOriginal(String original)
|
|
||||||
{
|
|
||||||
this.original = original;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSmall()
|
|
||||||
{
|
|
||||||
return small;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSmall(String small)
|
|
||||||
{
|
|
||||||
this.small = small;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Thumb withSmall(String small)
|
|
||||||
{
|
|
||||||
this.small = small;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLarge()
|
|
||||||
{
|
|
||||||
return large;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLarge(String large)
|
|
||||||
{
|
|
||||||
this.large = large;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Thumb withLarge(String large)
|
|
||||||
{
|
|
||||||
this.large = large;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getXlarge()
|
|
||||||
{
|
|
||||||
return xlarge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setXlarge(String xlarge)
|
|
||||||
{
|
|
||||||
this.xlarge = xlarge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Thumb withXlarge(String xlarge)
|
|
||||||
{
|
|
||||||
this.xlarge = xlarge;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.common.impl.typeadapters.ActionTypeAdapterFactory;
|
|
||||||
import org.openhab.binding.lametrictime.api.common.impl.typeadapters.ApplicationTypeAdapterFactory;
|
|
||||||
import org.openhab.binding.lametrictime.api.common.impl.typeadapters.UpdateActionTypeAdapterFactory;
|
|
||||||
import org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported.JSR310TypeAdapters;
|
|
||||||
import org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported.RuntimeTypeAdapterFactory;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.BooleanParameter;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.IntegerParameter;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Parameter;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.StringParameter;
|
|
||||||
|
|
||||||
import com.google.gson.FieldNamingPolicy;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
|
|
||||||
public class GsonGenerator
|
|
||||||
{
|
|
||||||
public static Gson create()
|
|
||||||
{
|
|
||||||
return create(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Gson create(boolean prettyPrint)
|
|
||||||
{
|
|
||||||
GsonBuilder builder = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
|
|
||||||
.registerTypeAdapterFactory(new ApplicationTypeAdapterFactory())
|
|
||||||
.registerTypeAdapterFactory(new ActionTypeAdapterFactory())
|
|
||||||
.registerTypeAdapterFactory(new UpdateActionTypeAdapterFactory())
|
|
||||||
.registerTypeAdapterFactory(RuntimeTypeAdapterFactory.of(Parameter.class,
|
|
||||||
"data_type")
|
|
||||||
.registerSubtype(BooleanParameter.class,
|
|
||||||
"bool")
|
|
||||||
.registerSubtype(StringParameter.class,
|
|
||||||
"string")
|
|
||||||
.registerSubtype(IntegerParameter.class,
|
|
||||||
"int"));
|
|
||||||
|
|
||||||
// add Java 8 Time API support
|
|
||||||
JSR310TypeAdapters.registerJSR310TypeAdapters(builder);
|
|
||||||
|
|
||||||
if (prettyPrint)
|
|
||||||
{
|
|
||||||
builder.setPrettyPrinting();
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
// @formatter:off
|
|
||||||
private GsonGenerator() {}
|
|
||||||
// @formatter:on
|
|
||||||
}
|
|
@ -1,75 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters;
|
|
||||||
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported.CustomizedTypeAdapterFactory;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.UpdateAction;
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
public class UpdateActionTypeAdapterFactory extends CustomizedTypeAdapterFactory<UpdateAction>
|
|
||||||
{
|
|
||||||
private static final String PROPERTY_PARAMETERS = "params";
|
|
||||||
private static final String PROPERTY_VALUE = "value";
|
|
||||||
|
|
||||||
public UpdateActionTypeAdapterFactory()
|
|
||||||
{
|
|
||||||
super(UpdateAction.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void beforeWrite(UpdateAction source, JsonElement toSerialize)
|
|
||||||
{
|
|
||||||
if (toSerialize == null || toSerialize.isJsonNull())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonObject actionObj = toSerialize.getAsJsonObject();
|
|
||||||
if (actionObj == null || actionObj.isJsonNull())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// rewrite parameters map from {name => Parameter} to {name => value}
|
|
||||||
JsonElement paramsElem = actionObj.get(PROPERTY_PARAMETERS);
|
|
||||||
if (paramsElem != null && !paramsElem.isJsonNull())
|
|
||||||
{
|
|
||||||
JsonObject paramsObj = paramsElem.getAsJsonObject();
|
|
||||||
actionObj.remove(PROPERTY_PARAMETERS);
|
|
||||||
|
|
||||||
JsonObject newParamsObj = new JsonObject();
|
|
||||||
for (Entry<String, JsonElement> entry : paramsObj.entrySet())
|
|
||||||
{
|
|
||||||
newParamsObj.add(entry.getKey(),
|
|
||||||
entry.getValue()
|
|
||||||
.getAsJsonObject()
|
|
||||||
.getAsJsonPrimitive(PROPERTY_VALUE));
|
|
||||||
}
|
|
||||||
actionObj.add(PROPERTY_PARAMETERS, newParamsObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void afterRead(JsonElement deserialized)
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException(UpdateAction.class.getName()
|
|
||||||
+ " cannot be derialized");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstract type adapter for jsr310 date-time types.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
abstract class DateTimeTypeAdapter<T> extends TemporalTypeAdapter<T> {
|
|
||||||
|
|
||||||
DateTimeTypeAdapter(Function<String, T> parseFunction) {
|
|
||||||
super(parseFunction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String preProcess(String in) {
|
|
||||||
if (in.endsWith("+0000")) {
|
|
||||||
return in.substring(0, in.length()-5) + "Z";
|
|
||||||
}
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link Duration} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class DurationTypeAdapter extends TemporalTypeAdapter<Duration> {
|
|
||||||
|
|
||||||
public DurationTypeAdapter() {
|
|
||||||
super(Duration::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link Instant} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class InstantTypeAdapter extends DateTimeTypeAdapter<Instant> {
|
|
||||||
|
|
||||||
public InstantTypeAdapter() {
|
|
||||||
super(Instant::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,109 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
|
|
||||||
import java.time.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper methods to register JSR310 type adapters.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class JSR310TypeAdapters {
|
|
||||||
|
|
||||||
private JSR310TypeAdapters() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerDurationTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(Duration.class, new DurationTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerInstantTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(Instant.class, new InstantTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerLocalDateTimeTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerLocalDateTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(LocalDate.class, new LocalDateTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerLocalTimeTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(LocalTime.class, new LocalTimeTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerMonthDayTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(MonthDay.class, new MonthDayTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerOffsetDateTimeTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerOffsetTimeTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(OffsetTime.class, new OffsetTimeTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerPeriodTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(Period.class, new PeriodTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerYearMonthTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(YearMonth.class, new YearMonthTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerYearTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(Year.class, new YearTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static GsonBuilder registerZonedDateTimeTypeAdapter(GsonBuilder gsonBuilder) {
|
|
||||||
return gsonBuilder.registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeTypeAdapter());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper method to register all the available JSR310 adapters at once.
|
|
||||||
* @param gsonBuilder the gsonBuilder on which all the JSR310 adapters must be registered.
|
|
||||||
* @return the gsonBuilder with the JSR310 adapters registered.
|
|
||||||
*/
|
|
||||||
public static GsonBuilder registerJSR310TypeAdapters(GsonBuilder gsonBuilder) {
|
|
||||||
registerDurationTypeAdapter(gsonBuilder);
|
|
||||||
registerInstantTypeAdapter(gsonBuilder);
|
|
||||||
registerLocalDateTimeTypeAdapter(gsonBuilder);
|
|
||||||
registerLocalDateTypeAdapter(gsonBuilder);
|
|
||||||
registerLocalTimeTypeAdapter(gsonBuilder);
|
|
||||||
registerMonthDayTypeAdapter(gsonBuilder);
|
|
||||||
registerOffsetDateTimeTypeAdapter(gsonBuilder);
|
|
||||||
registerOffsetTimeTypeAdapter(gsonBuilder);
|
|
||||||
registerPeriodTypeAdapter(gsonBuilder);
|
|
||||||
registerYearMonthTypeAdapter(gsonBuilder);
|
|
||||||
registerYearTypeAdapter(gsonBuilder);
|
|
||||||
registerZonedDateTimeTypeAdapter(gsonBuilder);
|
|
||||||
|
|
||||||
return gsonBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link LocalDateTime} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class LocalDateTimeTypeAdapter extends DateTimeTypeAdapter<LocalDateTime> {
|
|
||||||
|
|
||||||
public LocalDateTimeTypeAdapter() {
|
|
||||||
super(LocalDateTime::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link LocalDate} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class LocalDateTypeAdapter extends TemporalTypeAdapter<LocalDate> {
|
|
||||||
|
|
||||||
public LocalDateTypeAdapter() {
|
|
||||||
super(LocalDate::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.LocalTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link LocalTime} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class LocalTimeTypeAdapter extends TemporalTypeAdapter<LocalTime> {
|
|
||||||
|
|
||||||
public LocalTimeTypeAdapter() {
|
|
||||||
super(LocalTime::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.MonthDay;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link MonthDay} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class MonthDayTypeAdapter extends TemporalTypeAdapter<MonthDay> {
|
|
||||||
|
|
||||||
public MonthDayTypeAdapter() {
|
|
||||||
super(MonthDay::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link OffsetDateTime} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class OffsetDateTimeTypeAdapter extends DateTimeTypeAdapter<OffsetDateTime> {
|
|
||||||
|
|
||||||
public OffsetDateTimeTypeAdapter() {
|
|
||||||
super(OffsetDateTime::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.OffsetTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link OffsetTime} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class OffsetTimeTypeAdapter extends TemporalTypeAdapter<OffsetTime> {
|
|
||||||
|
|
||||||
public OffsetTimeTypeAdapter() {
|
|
||||||
super(OffsetTime::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.Period;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link Period} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class PeriodTypeAdapter extends TemporalTypeAdapter<Period> {
|
|
||||||
|
|
||||||
public PeriodTypeAdapter() {
|
|
||||||
super(Period::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,420 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 Google Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copied from
|
|
||||||
* https://raw.githubusercontent.com/google/gson/master/extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java
|
|
||||||
* and repackaged here with additional content from
|
|
||||||
* com.google.gson.internal.{Streams,TypeAdapters,LazilyParsedNumber}
|
|
||||||
* to avoid using the internal package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.io.EOFException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectStreamException;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonIOException;
|
|
||||||
import com.google.gson.JsonNull;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
import com.google.gson.JsonPrimitive;
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
|
||||||
import com.google.gson.TypeAdapter;
|
|
||||||
import com.google.gson.TypeAdapterFactory;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import com.google.gson.stream.JsonReader;
|
|
||||||
import com.google.gson.stream.JsonWriter;
|
|
||||||
import com.google.gson.stream.MalformedJsonException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adapts values whose runtime type may differ from their declaration type. This
|
|
||||||
* is necessary when a field's type is not the same type that GSON should create
|
|
||||||
* when deserializing that field. For example, consider these types:
|
|
||||||
* <pre> {@code
|
|
||||||
* abstract class Shape {
|
|
||||||
* int x;
|
|
||||||
* int y;
|
|
||||||
* }
|
|
||||||
* class Circle extends Shape {
|
|
||||||
* int radius;
|
|
||||||
* }
|
|
||||||
* class Rectangle extends Shape {
|
|
||||||
* int width;
|
|
||||||
* int height;
|
|
||||||
* }
|
|
||||||
* class Diamond extends Shape {
|
|
||||||
* int width;
|
|
||||||
* int height;
|
|
||||||
* }
|
|
||||||
* class Drawing {
|
|
||||||
* Shape bottomShape;
|
|
||||||
* Shape topShape;
|
|
||||||
* }
|
|
||||||
* }</pre>
|
|
||||||
* <p>Without additional type information, the serialized JSON is ambiguous. Is
|
|
||||||
* the bottom shape in this drawing a rectangle or a diamond? <pre> {@code
|
|
||||||
* {
|
|
||||||
* "bottomShape": {
|
|
||||||
* "width": 10,
|
|
||||||
* "height": 5,
|
|
||||||
* "x": 0,
|
|
||||||
* "y": 0
|
|
||||||
* },
|
|
||||||
* "topShape": {
|
|
||||||
* "radius": 2,
|
|
||||||
* "x": 4,
|
|
||||||
* "y": 1
|
|
||||||
* }
|
|
||||||
* }}</pre>
|
|
||||||
* This class addresses this problem by adding type information to the
|
|
||||||
* serialized JSON and honoring that type information when the JSON is
|
|
||||||
* deserialized: <pre> {@code
|
|
||||||
* {
|
|
||||||
* "bottomShape": {
|
|
||||||
* "type": "Diamond",
|
|
||||||
* "width": 10,
|
|
||||||
* "height": 5,
|
|
||||||
* "x": 0,
|
|
||||||
* "y": 0
|
|
||||||
* },
|
|
||||||
* "topShape": {
|
|
||||||
* "type": "Circle",
|
|
||||||
* "radius": 2,
|
|
||||||
* "x": 4,
|
|
||||||
* "y": 1
|
|
||||||
* }
|
|
||||||
* }}</pre>
|
|
||||||
* Both the type field name ({@code "type"}) and the type labels ({@code
|
|
||||||
* "Rectangle"}) are configurable.
|
|
||||||
*
|
|
||||||
* <h3>Registering Types</h3>
|
|
||||||
* Create a {@code RuntimeTypeAdapterFactory} by passing the base type and type field
|
|
||||||
* name to the {@link #of} factory method. If you don't supply an explicit type
|
|
||||||
* field name, {@code "type"} will be used. <pre> {@code
|
|
||||||
* RuntimeTypeAdapterFactory<Shape> shapeAdapterFactory
|
|
||||||
* = RuntimeTypeAdapterFactory.of(Shape.class, "type");
|
|
||||||
* }</pre>
|
|
||||||
* Next register all of your subtypes. Every subtype must be explicitly
|
|
||||||
* registered. This protects your application from injection attacks. If you
|
|
||||||
* don't supply an explicit type label, the type's simple name will be used.
|
|
||||||
* <pre> {@code
|
|
||||||
* shapeAdapter.registerSubtype(Rectangle.class, "Rectangle");
|
|
||||||
* shapeAdapter.registerSubtype(Circle.class, "Circle");
|
|
||||||
* shapeAdapter.registerSubtype(Diamond.class, "Diamond");
|
|
||||||
* }</pre>
|
|
||||||
* Finally, register the type adapter factory in your application's GSON builder:
|
|
||||||
* <pre> {@code
|
|
||||||
* Gson gson = new GsonBuilder()
|
|
||||||
* .registerTypeAdapterFactory(shapeAdapterFactory)
|
|
||||||
* .create();
|
|
||||||
* }</pre>
|
|
||||||
* Like {@code GsonBuilder}, this API supports chaining: <pre> {@code
|
|
||||||
* RuntimeTypeAdapterFactory<Shape> shapeAdapterFactory = RuntimeTypeAdapterFactory.of(Shape.class)
|
|
||||||
* .registerSubtype(Rectangle.class)
|
|
||||||
* .registerSubtype(Circle.class)
|
|
||||||
* .registerSubtype(Diamond.class);
|
|
||||||
* }</pre>
|
|
||||||
*/
|
|
||||||
public final class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory {
|
|
||||||
private final Class<?> baseType;
|
|
||||||
private final String typeFieldName;
|
|
||||||
private final Map<String, Class<?>> labelToSubtype = new LinkedHashMap<String, Class<?>>();
|
|
||||||
private final Map<Class<?>, String> subtypeToLabel = new LinkedHashMap<Class<?>, String>();
|
|
||||||
|
|
||||||
private RuntimeTypeAdapterFactory(Class<?> baseType, String typeFieldName) {
|
|
||||||
if (typeFieldName == null || baseType == null) {
|
|
||||||
throw new NullPointerException();
|
|
||||||
}
|
|
||||||
this.baseType = baseType;
|
|
||||||
this.typeFieldName = typeFieldName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new runtime type adapter using for {@code baseType} using {@code
|
|
||||||
* typeFieldName} as the type field name. Type field names are case sensitive.
|
|
||||||
*/
|
|
||||||
public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType, String typeFieldName) {
|
|
||||||
return new RuntimeTypeAdapterFactory<T>(baseType, typeFieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new runtime type adapter for {@code baseType} using {@code "type"} as
|
|
||||||
* the type field name.
|
|
||||||
*/
|
|
||||||
public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType) {
|
|
||||||
return new RuntimeTypeAdapterFactory<T>(baseType, "type");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers {@code type} identified by {@code label}. Labels are case
|
|
||||||
* sensitive.
|
|
||||||
*
|
|
||||||
* @throws IllegalArgumentException if either {@code type} or {@code label}
|
|
||||||
* have already been registered on this type adapter.
|
|
||||||
*/
|
|
||||||
public RuntimeTypeAdapterFactory<T> registerSubtype(Class<? extends T> type, String label) {
|
|
||||||
if (type == null || label == null) {
|
|
||||||
throw new NullPointerException();
|
|
||||||
}
|
|
||||||
if (subtypeToLabel.containsKey(type) || labelToSubtype.containsKey(label)) {
|
|
||||||
throw new IllegalArgumentException("types and labels must be unique");
|
|
||||||
}
|
|
||||||
labelToSubtype.put(label, type);
|
|
||||||
subtypeToLabel.put(type, label);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers {@code type} identified by its {@link Class#getSimpleName simple
|
|
||||||
* name}. Labels are case sensitive.
|
|
||||||
*
|
|
||||||
* @throws IllegalArgumentException if either {@code type} or its simple name
|
|
||||||
* have already been registered on this type adapter.
|
|
||||||
*/
|
|
||||||
public RuntimeTypeAdapterFactory<T> registerSubtype(Class<? extends T> type) {
|
|
||||||
return registerSubtype(type, type.getSimpleName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public <R> TypeAdapter<R> create(Gson gson, TypeToken<R> type) {
|
|
||||||
if (type.getRawType() != baseType) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Map<String, TypeAdapter<?>> labelToDelegate
|
|
||||||
= new LinkedHashMap<String, TypeAdapter<?>>();
|
|
||||||
final Map<Class<?>, TypeAdapter<?>> subtypeToDelegate
|
|
||||||
= new LinkedHashMap<Class<?>, TypeAdapter<?>>();
|
|
||||||
for (Map.Entry<String, Class<?>> entry : labelToSubtype.entrySet()) {
|
|
||||||
TypeAdapter<?> delegate = gson.getDelegateAdapter(this, TypeToken.get(entry.getValue()));
|
|
||||||
labelToDelegate.put(entry.getKey(), delegate);
|
|
||||||
subtypeToDelegate.put(entry.getValue(), delegate);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new TypeAdapter<R>() {
|
|
||||||
@Override public R read(JsonReader in) throws IOException {
|
|
||||||
JsonElement jsonElement = RuntimeTypeAdapterFactory.parse(in);
|
|
||||||
JsonElement labelJsonElement = jsonElement.getAsJsonObject().remove(typeFieldName);
|
|
||||||
if (labelJsonElement == null) {
|
|
||||||
throw new JsonParseException("cannot deserialize " + baseType
|
|
||||||
+ " because it does not define a field named " + typeFieldName);
|
|
||||||
}
|
|
||||||
String label = labelJsonElement.getAsString();
|
|
||||||
@SuppressWarnings("unchecked") // registration requires that subtype extends T
|
|
||||||
TypeAdapter<R> delegate = (TypeAdapter<R>) labelToDelegate.get(label);
|
|
||||||
if (delegate == null) {
|
|
||||||
throw new JsonParseException("cannot deserialize " + baseType + " subtype named "
|
|
||||||
+ label + "; did you forget to register a subtype?");
|
|
||||||
}
|
|
||||||
return delegate.fromJsonTree(jsonElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void write(JsonWriter out, R value) throws IOException {
|
|
||||||
Class<?> srcType = value.getClass();
|
|
||||||
String label = subtypeToLabel.get(srcType);
|
|
||||||
@SuppressWarnings("unchecked") // registration requires that subtype extends T
|
|
||||||
TypeAdapter<R> delegate = (TypeAdapter<R>) subtypeToDelegate.get(srcType);
|
|
||||||
if (delegate == null) {
|
|
||||||
throw new JsonParseException("cannot serialize " + srcType.getName()
|
|
||||||
+ "; did you forget to register a subtype?");
|
|
||||||
}
|
|
||||||
JsonObject jsonObject = delegate.toJsonTree(value).getAsJsonObject();
|
|
||||||
if (jsonObject.has(typeFieldName)) {
|
|
||||||
throw new JsonParseException("cannot serialize " + srcType.getName()
|
|
||||||
+ " because it already defines a field named " + typeFieldName);
|
|
||||||
}
|
|
||||||
JsonObject clone = new JsonObject();
|
|
||||||
clone.add(typeFieldName, new JsonPrimitive(label));
|
|
||||||
for (Map.Entry<String, JsonElement> e : jsonObject.entrySet()) {
|
|
||||||
clone.add(e.getKey(), e.getValue());
|
|
||||||
}
|
|
||||||
RuntimeTypeAdapterFactory.write(clone, out);
|
|
||||||
}
|
|
||||||
}.nullSafe();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Takes a reader in any state and returns the next value as a JsonElement.
|
|
||||||
*/
|
|
||||||
private static JsonElement parse(JsonReader reader) throws JsonParseException {
|
|
||||||
boolean isEmpty = true;
|
|
||||||
try {
|
|
||||||
reader.peek();
|
|
||||||
isEmpty = false;
|
|
||||||
return RuntimeTypeAdapterFactory.JSON_ELEMENT.read(reader);
|
|
||||||
} catch (EOFException e) {
|
|
||||||
/*
|
|
||||||
* For compatibility with JSON 1.5 and earlier, we return a JsonNull for
|
|
||||||
* empty documents instead of throwing.
|
|
||||||
*/
|
|
||||||
if (isEmpty) {
|
|
||||||
return JsonNull.INSTANCE;
|
|
||||||
}
|
|
||||||
// The stream ended prematurely so it is likely a syntax error.
|
|
||||||
throw new JsonSyntaxException(e);
|
|
||||||
} catch (MalformedJsonException e) {
|
|
||||||
throw new JsonSyntaxException(e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new JsonIOException(e);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
throw new JsonSyntaxException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the JSON element to the writer, recursively.
|
|
||||||
*/
|
|
||||||
private static void write(JsonElement element, JsonWriter writer) throws IOException {
|
|
||||||
RuntimeTypeAdapterFactory.JSON_ELEMENT.write(writer, element);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final TypeAdapter<JsonElement> JSON_ELEMENT = new TypeAdapter<JsonElement>() {
|
|
||||||
@Override public JsonElement read(JsonReader in) throws IOException {
|
|
||||||
switch (in.peek()) {
|
|
||||||
case STRING:
|
|
||||||
return new JsonPrimitive(in.nextString());
|
|
||||||
case NUMBER:
|
|
||||||
String number = in.nextString();
|
|
||||||
return new JsonPrimitive(new LazilyParsedNumber(number));
|
|
||||||
case BOOLEAN:
|
|
||||||
return new JsonPrimitive(in.nextBoolean());
|
|
||||||
case NULL:
|
|
||||||
in.nextNull();
|
|
||||||
return JsonNull.INSTANCE;
|
|
||||||
case BEGIN_ARRAY:
|
|
||||||
JsonArray array = new JsonArray();
|
|
||||||
in.beginArray();
|
|
||||||
while (in.hasNext()) {
|
|
||||||
array.add(read(in));
|
|
||||||
}
|
|
||||||
in.endArray();
|
|
||||||
return array;
|
|
||||||
case BEGIN_OBJECT:
|
|
||||||
JsonObject object = new JsonObject();
|
|
||||||
in.beginObject();
|
|
||||||
while (in.hasNext()) {
|
|
||||||
object.add(in.nextName(), read(in));
|
|
||||||
}
|
|
||||||
in.endObject();
|
|
||||||
return object;
|
|
||||||
case END_DOCUMENT:
|
|
||||||
case NAME:
|
|
||||||
case END_OBJECT:
|
|
||||||
case END_ARRAY:
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void write(JsonWriter out, JsonElement value) throws IOException {
|
|
||||||
if (value == null || value.isJsonNull()) {
|
|
||||||
out.nullValue();
|
|
||||||
} else if (value.isJsonPrimitive()) {
|
|
||||||
JsonPrimitive primitive = value.getAsJsonPrimitive();
|
|
||||||
if (primitive.isNumber()) {
|
|
||||||
out.value(primitive.getAsNumber());
|
|
||||||
} else if (primitive.isBoolean()) {
|
|
||||||
out.value(primitive.getAsBoolean());
|
|
||||||
} else {
|
|
||||||
out.value(primitive.getAsString());
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (value.isJsonArray()) {
|
|
||||||
out.beginArray();
|
|
||||||
for (JsonElement e : value.getAsJsonArray()) {
|
|
||||||
write(out, e);
|
|
||||||
}
|
|
||||||
out.endArray();
|
|
||||||
|
|
||||||
} else if (value.isJsonObject()) {
|
|
||||||
out.beginObject();
|
|
||||||
for (Map.Entry<String, JsonElement> e : value.getAsJsonObject().entrySet()) {
|
|
||||||
out.name(e.getKey());
|
|
||||||
write(out, e.getValue());
|
|
||||||
}
|
|
||||||
out.endObject();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Couldn't write " + value.getClass());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class holds a number value that is lazily converted to a specific number type
|
|
||||||
*
|
|
||||||
* @author Inderjeet Singh
|
|
||||||
*/
|
|
||||||
public static final class LazilyParsedNumber extends Number {
|
|
||||||
private final String value;
|
|
||||||
|
|
||||||
public LazilyParsedNumber(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int intValue() {
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(value);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
try {
|
|
||||||
return (int) Long.parseLong(value);
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
return new BigDecimal(value).intValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long longValue() {
|
|
||||||
try {
|
|
||||||
return Long.parseLong(value);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return new BigDecimal(value).longValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float floatValue() {
|
|
||||||
return Float.parseFloat(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double doubleValue() {
|
|
||||||
return Double.parseDouble(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If somebody is unlucky enough to have to serialize one of these, serialize
|
|
||||||
* it as a BigDecimal so that they won't need Gson on the other side to
|
|
||||||
* deserialize it.
|
|
||||||
*/
|
|
||||||
private Object writeReplace() throws ObjectStreamException {
|
|
||||||
return new BigDecimal(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import com.google.gson.TypeAdapter;
|
|
||||||
import com.google.gson.stream.JsonReader;
|
|
||||||
import com.google.gson.stream.JsonToken;
|
|
||||||
import com.google.gson.stream.JsonWriter;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.time.temporal.TemporalAccessor;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Abstract type adapter for jsr310 date-time types.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
abstract class TemporalTypeAdapter<T> extends TypeAdapter<T> {
|
|
||||||
|
|
||||||
Function<String, T> parseFunction;
|
|
||||||
|
|
||||||
TemporalTypeAdapter(Function<String, T> parseFunction) {
|
|
||||||
Objects.requireNonNull(parseFunction);
|
|
||||||
this.parseFunction = parseFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(JsonWriter out, T value) throws IOException {
|
|
||||||
if (value == null) {
|
|
||||||
out.nullValue();
|
|
||||||
} else {
|
|
||||||
out.value(value.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T read(JsonReader in) throws IOException {
|
|
||||||
if (in.peek() == JsonToken.NULL) {
|
|
||||||
in.nextNull();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String temporalString = preProcess(in.nextString());
|
|
||||||
return parseFunction.apply(temporalString);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String preProcess(String in) {
|
|
||||||
return in;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.YearMonth;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link YearMonth} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class YearMonthTypeAdapter extends TemporalTypeAdapter<YearMonth> {
|
|
||||||
|
|
||||||
public YearMonthTypeAdapter() {
|
|
||||||
super(YearMonth::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.Year;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link Year} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class YearTypeAdapter extends TemporalTypeAdapter<Year> {
|
|
||||||
|
|
||||||
public YearTypeAdapter() {
|
|
||||||
super(Year::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 Gson Type Adapter Authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src
|
|
||||||
* and repackaged to avoid the default package.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
|
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type adapter for jsr310 {@link ZonedDateTime} class.
|
|
||||||
*
|
|
||||||
* @author Christophe Bornet
|
|
||||||
*/
|
|
||||||
public class ZonedDateTimeTypeAdapter extends DateTimeTypeAdapter<ZonedDateTime> {
|
|
||||||
|
|
||||||
public ZonedDateTimeTypeAdapter() {
|
|
||||||
super(ZonedDateTime::parse);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.impl;
|
|
||||||
|
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.model.Icon;
|
|
||||||
|
|
||||||
public abstract class AbstractDataIcon implements Icon
|
|
||||||
{
|
|
||||||
private volatile Object CONFIGURE_FLAG;
|
|
||||||
|
|
||||||
private String type;
|
|
||||||
private byte[] data;
|
|
||||||
|
|
||||||
protected void configure()
|
|
||||||
{
|
|
||||||
if (CONFIGURE_FLAG == null)
|
|
||||||
{
|
|
||||||
synchronized (this)
|
|
||||||
{
|
|
||||||
if (CONFIGURE_FLAG == null)
|
|
||||||
{
|
|
||||||
populateFields();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getType()
|
|
||||||
{
|
|
||||||
configure();
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected byte[] getData()
|
|
||||||
{
|
|
||||||
configure();
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setData(byte[] data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toRaw()
|
|
||||||
{
|
|
||||||
return new StringBuilder().append("data:")
|
|
||||||
.append(getType())
|
|
||||||
.append(";base64,")
|
|
||||||
.append(Base64.getEncoder().encodeToString(getData()))
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void populateFields();
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.impl;
|
|
||||||
|
|
||||||
public class DataIcon extends AbstractDataIcon
|
|
||||||
{
|
|
||||||
public DataIcon(String mimeType, byte[] data)
|
|
||||||
{
|
|
||||||
setType(mimeType);
|
|
||||||
setData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure()
|
|
||||||
{
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void populateFields()
|
|
||||||
{
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.impl;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
import javax.activation.MimetypesFileTypeMap;
|
|
||||||
|
|
||||||
public class FileIcon extends AbstractDataIcon
|
|
||||||
{
|
|
||||||
private final MimetypesFileTypeMap mimeTypeMap = new MimetypesFileTypeMap();
|
|
||||||
|
|
||||||
private final Path path;
|
|
||||||
|
|
||||||
public FileIcon(File file)
|
|
||||||
{
|
|
||||||
this(file.toPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileIcon(Path path)
|
|
||||||
{
|
|
||||||
this.path = path;
|
|
||||||
mimeTypeMap.addMimeTypes("image/png png PNG");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void populateFields()
|
|
||||||
{
|
|
||||||
setType(mimeTypeMap.getContentType(path.toFile()));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
setData(Files.readAllBytes(path));
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.impl;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import javax.ws.rs.client.Client;
|
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
|
||||||
import javax.ws.rs.core.Response;
|
|
||||||
|
|
||||||
public class HTTPIcon extends AbstractDataIcon
|
|
||||||
{
|
|
||||||
private final URI uri;
|
|
||||||
|
|
||||||
public HTTPIcon(String uri)
|
|
||||||
{
|
|
||||||
this(URI.create(uri));
|
|
||||||
}
|
|
||||||
|
|
||||||
public HTTPIcon(URI uri)
|
|
||||||
{
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void populateFields()
|
|
||||||
{
|
|
||||||
Client client = ClientBuilder.newBuilder().build();
|
|
||||||
Response response = client.target(uri).request().get();
|
|
||||||
|
|
||||||
setType(response.getMediaType().toString());
|
|
||||||
setData(response.readEntity(byte[].class));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.impl;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.model.Icon;
|
|
||||||
|
|
||||||
public class KeyIcon implements Icon
|
|
||||||
{
|
|
||||||
private final String key;
|
|
||||||
|
|
||||||
public KeyIcon(String key)
|
|
||||||
{
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toRaw()
|
|
||||||
{
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,334 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.impl;
|
|
||||||
|
|
||||||
import static org.openhab.binding.lametrictime.api.model.ApiValue.raw;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.Configuration;
|
|
||||||
import org.openhab.binding.lametrictime.api.LaMetricTime;
|
|
||||||
import org.openhab.binding.lametrictime.api.cloud.CloudConfiguration;
|
|
||||||
import org.openhab.binding.lametrictime.api.cloud.LaMetricTimeCloud;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.ApplicationActionException;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.ApplicationActivationException;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.ApplicationNotFoundException;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.LaMetricTimeLocal;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.LocalConfiguration;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.NotificationCreationException;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.UpdateException;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Application;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Audio;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Bluetooth;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Display;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Frame;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Notification;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.NotificationModel;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.UpdateAction;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Widget;
|
|
||||||
import org.openhab.binding.lametrictime.api.model.CoreAction;
|
|
||||||
import org.openhab.binding.lametrictime.api.model.CoreApplication;
|
|
||||||
import org.openhab.binding.lametrictime.api.model.CoreApps;
|
|
||||||
import org.openhab.binding.lametrictime.api.model.Icon;
|
|
||||||
import org.openhab.binding.lametrictime.api.model.Icons;
|
|
||||||
import org.openhab.binding.lametrictime.api.model.enums.BrightnessMode;
|
|
||||||
import org.openhab.binding.lametrictime.api.model.enums.Priority;
|
|
||||||
import org.openhab.binding.lametrictime.api.model.enums.Sound;
|
|
||||||
|
|
||||||
public class LaMetricTimeImpl implements LaMetricTime
|
|
||||||
{
|
|
||||||
private final LaMetricTimeLocal local;
|
|
||||||
private final LaMetricTimeCloud cloud;
|
|
||||||
|
|
||||||
private final Object muteLock = new Object();
|
|
||||||
private Integer volumeSaveState;
|
|
||||||
|
|
||||||
public LaMetricTimeImpl(Configuration config)
|
|
||||||
{
|
|
||||||
this(config.getLocalConfig(), config.getCloudConfig());
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaMetricTimeImpl(Configuration config, ClientBuilder clientBuilder)
|
|
||||||
{
|
|
||||||
this(config.getLocalConfig(), config.getCloudConfig(), clientBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaMetricTimeImpl(LocalConfiguration localConfig, CloudConfiguration cloudConfig)
|
|
||||||
{
|
|
||||||
this.local = LaMetricTimeLocal.create(localConfig);
|
|
||||||
this.cloud = LaMetricTimeCloud.create(cloudConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaMetricTimeImpl(LocalConfiguration localConfig,
|
|
||||||
CloudConfiguration cloudConfig,
|
|
||||||
ClientBuilder clientBuilder)
|
|
||||||
{
|
|
||||||
this.local = LaMetricTimeLocal.create(localConfig, clientBuilder);
|
|
||||||
this.cloud = LaMetricTimeCloud.create(cloudConfig, clientBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVersion()
|
|
||||||
{
|
|
||||||
return local.getApi().getApiVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String notifyInfo(String message) throws NotificationCreationException
|
|
||||||
{
|
|
||||||
return notify(message, Priority.INFO, Icons.key("i1248"), Sound.NOTIFICATION, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String notifyWarning(String message) throws NotificationCreationException
|
|
||||||
{
|
|
||||||
return notify(message, Priority.WARNING, Icons.key("a2098"), Sound.NOTIFICATION2, 2, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String notifyCritical(String message) throws NotificationCreationException
|
|
||||||
{
|
|
||||||
return notify(message, Priority.CRITICAL, Icons.key("a4787"), Sound.ALARM1, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String notify(String message,
|
|
||||||
Priority priority,
|
|
||||||
Icon icon,
|
|
||||||
Sound sound,
|
|
||||||
int messageRepeat,
|
|
||||||
int soundRepeat) throws NotificationCreationException
|
|
||||||
{
|
|
||||||
// @formatter:off
|
|
||||||
NotificationModel model = new NotificationModel()
|
|
||||||
.withCycles(messageRepeat)
|
|
||||||
.withFrames(Arrays.asList(new Frame().withText(message)
|
|
||||||
.withIcon(raw(icon))));
|
|
||||||
if (sound != null)
|
|
||||||
{
|
|
||||||
model.setSound(new org.openhab.binding.lametrictime.api.local.model.Sound()
|
|
||||||
.withCategory(raw(sound.getCategory()))
|
|
||||||
.withId(raw(sound))
|
|
||||||
.withRepeat(soundRepeat));
|
|
||||||
}
|
|
||||||
// @formatter:on
|
|
||||||
|
|
||||||
Notification notification = new Notification().withPriority(raw(priority)).withModel(model);
|
|
||||||
return local.createNotification(notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Application getClock()
|
|
||||||
{
|
|
||||||
return getApplication(CoreApps.clock());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Application getCountdown()
|
|
||||||
{
|
|
||||||
return getApplication(CoreApps.countdown());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Application getRadio()
|
|
||||||
{
|
|
||||||
return getApplication(CoreApps.radio());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Application getStopwatch()
|
|
||||||
{
|
|
||||||
return getApplication(CoreApps.stopwatch());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Application getWeather()
|
|
||||||
{
|
|
||||||
return getApplication(CoreApps.weather());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Application getApplication(CoreApplication coreApp)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return getLocalApi().getApplication(coreApp.getPackageName());
|
|
||||||
}
|
|
||||||
catch (ApplicationNotFoundException e)
|
|
||||||
{
|
|
||||||
// core apps should never throw errors
|
|
||||||
throw new RuntimeException("Failed to retrieve core application: "
|
|
||||||
+ coreApp.getPackageName(),
|
|
||||||
e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Application getApplication(String name) throws ApplicationNotFoundException
|
|
||||||
{
|
|
||||||
return getLocalApi().getApplication(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void activateApplication(CoreApplication coreApp)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
activateApplication(getApplication(coreApp));
|
|
||||||
}
|
|
||||||
catch (ApplicationActivationException e)
|
|
||||||
{
|
|
||||||
// core apps should never throw errors
|
|
||||||
throw new RuntimeException("Failed to activate core application: "
|
|
||||||
+ coreApp.getPackageName(),
|
|
||||||
e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void activateApplication(Application app) throws ApplicationActivationException
|
|
||||||
{
|
|
||||||
getLocalApi().activateApplication(app.getPackageName(), getFirstWidgetId(app));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void activateWidget(Widget widget) throws ApplicationActivationException
|
|
||||||
{
|
|
||||||
getLocalApi().activateApplication(widget.getPackageName(), widget.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doAction(CoreAction coreAction)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
doAction(getApplication(coreAction.getApp()), coreAction.getAction());
|
|
||||||
}
|
|
||||||
catch (ApplicationActionException e)
|
|
||||||
{
|
|
||||||
// core apps should never throw errors
|
|
||||||
throw new RuntimeException("Failed to execute weather forecast action", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doAction(Application app, UpdateAction action) throws ApplicationActionException
|
|
||||||
{
|
|
||||||
getLocalApi().doAction(app.getPackageName(), getFirstWidgetId(app), action);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doAction(Widget widget, CoreAction coreAction) throws ApplicationActionException
|
|
||||||
{
|
|
||||||
doAction(widget, coreAction.getAction());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doAction(Widget widget, UpdateAction action) throws ApplicationActionException
|
|
||||||
{
|
|
||||||
getLocalApi().doAction(widget.getPackageName(), widget.getId(), action);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String getFirstWidgetId(Application app)
|
|
||||||
{
|
|
||||||
return app.getWidgets().firstKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Display setBrightness(int brightness) throws UpdateException
|
|
||||||
{
|
|
||||||
return local.updateDisplay(new Display().withBrightness(brightness)
|
|
||||||
.withBrightnessMode(raw(BrightnessMode.MANUAL)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Display setBrightnessMode(BrightnessMode mode) throws UpdateException
|
|
||||||
{
|
|
||||||
return local.updateDisplay(new Display().withBrightnessMode(raw(mode)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Audio setVolume(int volume) throws UpdateException
|
|
||||||
{
|
|
||||||
return local.updateAudio(new Audio().withVolume(volume));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Audio mute() throws UpdateException
|
|
||||||
{
|
|
||||||
synchronized (muteLock)
|
|
||||||
{
|
|
||||||
Audio audio = local.getAudio();
|
|
||||||
if (audio.getVolume() == 0)
|
|
||||||
{
|
|
||||||
return audio;
|
|
||||||
}
|
|
||||||
|
|
||||||
volumeSaveState = audio.getVolume();
|
|
||||||
return setVolume(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Audio unmute() throws UpdateException
|
|
||||||
{
|
|
||||||
synchronized (muteLock)
|
|
||||||
{
|
|
||||||
if (volumeSaveState == null)
|
|
||||||
{
|
|
||||||
Audio audio = local.getAudio();
|
|
||||||
if (audio.getVolume() == 0)
|
|
||||||
{
|
|
||||||
return setVolume(50);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return audio;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Audio audio = setVolume(volumeSaveState);
|
|
||||||
volumeSaveState = null;
|
|
||||||
return audio;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Bluetooth setBluetoothActive(boolean active) throws UpdateException
|
|
||||||
{
|
|
||||||
return local.updateBluetooth(new Bluetooth().withActive(active));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Bluetooth setBluetoothName(String name) throws UpdateException
|
|
||||||
{
|
|
||||||
return local.updateBluetooth(new Bluetooth().withName(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LaMetricTimeLocal getLocalApi()
|
|
||||||
{
|
|
||||||
return local;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LaMetricTimeCloud getCloudApi()
|
|
||||||
{
|
|
||||||
return cloud;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Failure;
|
|
||||||
|
|
||||||
public class ApplicationActionException extends LaMetricTimeException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public ApplicationActionException()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationActionException(String message)
|
|
||||||
{
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationActionException(Throwable cause)
|
|
||||||
{
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationActionException(String message, Throwable cause)
|
|
||||||
{
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationActionException(String message,
|
|
||||||
Throwable cause,
|
|
||||||
boolean enableSuppression,
|
|
||||||
boolean writableStackTrace)
|
|
||||||
{
|
|
||||||
super(message, cause, enableSuppression, writableStackTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationActionException(Failure failure)
|
|
||||||
{
|
|
||||||
super(failure);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Failure;
|
|
||||||
|
|
||||||
public class ApplicationActivationException extends LaMetricTimeException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public ApplicationActivationException()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationActivationException(String message)
|
|
||||||
{
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationActivationException(Throwable cause)
|
|
||||||
{
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationActivationException(String message, Throwable cause)
|
|
||||||
{
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationActivationException(String message,
|
|
||||||
Throwable cause,
|
|
||||||
boolean enableSuppression,
|
|
||||||
boolean writableStackTrace)
|
|
||||||
{
|
|
||||||
super(message, cause, enableSuppression, writableStackTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationActivationException(Failure failure)
|
|
||||||
{
|
|
||||||
super(failure);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Failure;
|
|
||||||
|
|
||||||
public class ApplicationNotFoundException extends LaMetricTimeException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public ApplicationNotFoundException()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationNotFoundException(String message)
|
|
||||||
{
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationNotFoundException(Throwable cause)
|
|
||||||
{
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationNotFoundException(String message, Throwable cause)
|
|
||||||
{
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationNotFoundException(String message,
|
|
||||||
Throwable cause,
|
|
||||||
boolean enableSuppression,
|
|
||||||
boolean writableStackTrace)
|
|
||||||
{
|
|
||||||
super(message, cause, enableSuppression, writableStackTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApplicationNotFoundException(Failure failure)
|
|
||||||
{
|
|
||||||
super(failure);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Error;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Failure;
|
|
||||||
|
|
||||||
public class LaMetricTimeException extends Exception
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public LaMetricTimeException()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaMetricTimeException(String message)
|
|
||||||
{
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaMetricTimeException(Throwable cause)
|
|
||||||
{
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaMetricTimeException(String message, Throwable cause)
|
|
||||||
{
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaMetricTimeException(String message,
|
|
||||||
Throwable cause,
|
|
||||||
boolean enableSuppression,
|
|
||||||
boolean writableStackTrace)
|
|
||||||
{
|
|
||||||
super(message, cause, enableSuppression, writableStackTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
public LaMetricTimeException(Failure failure)
|
|
||||||
{
|
|
||||||
super(buildMessage(failure));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String buildMessage(Failure failure)
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
|
|
||||||
List<Error> errors = failure.getErrors();
|
|
||||||
if (!errors.isEmpty())
|
|
||||||
{
|
|
||||||
builder.append(errors.get(0).getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 1; i < errors.size(); i++)
|
|
||||||
{
|
|
||||||
builder.append("; ").append(errors.get(i).getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.SortedMap;
|
|
||||||
|
|
||||||
import javax.ws.rs.client.ClientBuilder;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.impl.LaMetricTimeLocalImpl;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Api;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Application;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Audio;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Bluetooth;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Device;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Display;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Notification;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.UpdateAction;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.WidgetUpdates;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Wifi;
|
|
||||||
|
|
||||||
public interface LaMetricTimeLocal
|
|
||||||
{
|
|
||||||
public Api getApi();
|
|
||||||
|
|
||||||
public Device getDevice();
|
|
||||||
|
|
||||||
public String createNotification(Notification notification) throws NotificationCreationException;
|
|
||||||
|
|
||||||
public List<Notification> getNotifications();
|
|
||||||
|
|
||||||
public Notification getCurrentNotification();
|
|
||||||
|
|
||||||
public Notification getNotification(String id) throws NotificationNotFoundException;
|
|
||||||
|
|
||||||
public void deleteNotification(String id) throws NotificationNotFoundException;
|
|
||||||
|
|
||||||
public Display getDisplay();
|
|
||||||
|
|
||||||
public Display updateDisplay(Display display) throws UpdateException;
|
|
||||||
|
|
||||||
public Audio getAudio();
|
|
||||||
|
|
||||||
public Audio updateAudio(Audio audio) throws UpdateException;
|
|
||||||
|
|
||||||
public Bluetooth getBluetooth();
|
|
||||||
|
|
||||||
public Bluetooth updateBluetooth(Bluetooth bluetooth) throws UpdateException;
|
|
||||||
|
|
||||||
public Wifi getWifi();
|
|
||||||
|
|
||||||
public void updateApplication(String packageName,
|
|
||||||
String accessToken,
|
|
||||||
WidgetUpdates widgetUpdates) throws UpdateException;
|
|
||||||
|
|
||||||
public SortedMap<String, Application> getApplications();
|
|
||||||
|
|
||||||
public Application getApplication(String packageName) throws ApplicationNotFoundException;
|
|
||||||
|
|
||||||
public void activatePreviousApplication();
|
|
||||||
|
|
||||||
public void activateNextApplication();
|
|
||||||
|
|
||||||
public void activateApplication(String packageName,
|
|
||||||
String widgetId) throws ApplicationActivationException;
|
|
||||||
|
|
||||||
public void doAction(String packageName,
|
|
||||||
String widgetId,
|
|
||||||
UpdateAction action) throws ApplicationActionException;
|
|
||||||
|
|
||||||
public static LaMetricTimeLocal create(LocalConfiguration config)
|
|
||||||
{
|
|
||||||
return new LaMetricTimeLocalImpl(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LaMetricTimeLocal create(LocalConfiguration config, ClientBuilder clientBuilder)
|
|
||||||
{
|
|
||||||
return new LaMetricTimeLocalImpl(config, clientBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Failure;
|
|
||||||
|
|
||||||
public class NotificationCreationException extends LaMetricTimeException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public NotificationCreationException()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationCreationException(String message)
|
|
||||||
{
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationCreationException(Throwable cause)
|
|
||||||
{
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationCreationException(String message, Throwable cause)
|
|
||||||
{
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationCreationException(String message,
|
|
||||||
Throwable cause,
|
|
||||||
boolean enableSuppression,
|
|
||||||
boolean writableStackTrace)
|
|
||||||
{
|
|
||||||
super(message, cause, enableSuppression, writableStackTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationCreationException(Failure failure)
|
|
||||||
{
|
|
||||||
super(failure);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Failure;
|
|
||||||
|
|
||||||
public class NotificationNotFoundException extends LaMetricTimeException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public NotificationNotFoundException()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationNotFoundException(String message,
|
|
||||||
Throwable cause,
|
|
||||||
boolean enableSuppression,
|
|
||||||
boolean writableStackTrace)
|
|
||||||
{
|
|
||||||
super(message, cause, enableSuppression, writableStackTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationNotFoundException(String message, Throwable cause)
|
|
||||||
{
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationNotFoundException(String message)
|
|
||||||
{
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationNotFoundException(Throwable cause)
|
|
||||||
{
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationNotFoundException(Failure failure)
|
|
||||||
{
|
|
||||||
super(failure);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Failure;
|
|
||||||
|
|
||||||
public class UpdateException extends LaMetricTimeException
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public UpdateException()
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public UpdateException(String message)
|
|
||||||
{
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UpdateException(Throwable cause)
|
|
||||||
{
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UpdateException(String message, Throwable cause)
|
|
||||||
{
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UpdateException(String message,
|
|
||||||
Throwable cause,
|
|
||||||
boolean enableSuppression,
|
|
||||||
boolean writableStackTrace)
|
|
||||||
{
|
|
||||||
super(message, cause, enableSuppression, writableStackTrace);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UpdateException(Failure failure)
|
|
||||||
{
|
|
||||||
super(failure);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,122 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
import java.util.SortedMap;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
public class Action
|
|
||||||
{
|
|
||||||
private String id;
|
|
||||||
@SerializedName("params")
|
|
||||||
private SortedMap<String, Parameter> parameters;
|
|
||||||
|
|
||||||
public String getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action withId(String id)
|
|
||||||
{
|
|
||||||
setId(id);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SortedMap<String, Parameter> getParameters()
|
|
||||||
{
|
|
||||||
return parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setParameters(SortedMap<String, Parameter> parameters)
|
|
||||||
{
|
|
||||||
this.parameters = parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Action withParameters(SortedMap<String, Parameter> parameters)
|
|
||||||
{
|
|
||||||
setParameters(parameters);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
|
||||||
result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
if (this == obj)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Action other = (Action)obj;
|
|
||||||
if (id == null)
|
|
||||||
{
|
|
||||||
if (other.id != null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!id.equals(other.id))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (parameters == null)
|
|
||||||
{
|
|
||||||
if (other.parameters != null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!parameters.equals(other.parameters))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("Action [id=");
|
|
||||||
builder.append(id);
|
|
||||||
builder.append(", parameters=");
|
|
||||||
builder.append(parameters);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class Api
|
|
||||||
{
|
|
||||||
private String apiVersion;
|
|
||||||
private Endpoints endpoints;
|
|
||||||
|
|
||||||
public String getApiVersion()
|
|
||||||
{
|
|
||||||
return apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiVersion(String apiVersion)
|
|
||||||
{
|
|
||||||
this.apiVersion = apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Api withApiVersion(String apiVersion)
|
|
||||||
{
|
|
||||||
this.apiVersion = apiVersion;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Endpoints getEndpoints()
|
|
||||||
{
|
|
||||||
return endpoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndpoints(Endpoints endpoints)
|
|
||||||
{
|
|
||||||
this.endpoints = endpoints;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Api withEndpoints(Endpoints endpoints)
|
|
||||||
{
|
|
||||||
this.endpoints = endpoints;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("Api [apiVersion=");
|
|
||||||
builder.append(apiVersion);
|
|
||||||
builder.append(", endpoints=");
|
|
||||||
builder.append(endpoints);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class Audio
|
|
||||||
{
|
|
||||||
private Integer volume;
|
|
||||||
|
|
||||||
public Integer getVolume()
|
|
||||||
{
|
|
||||||
return volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVolume(Integer volume)
|
|
||||||
{
|
|
||||||
this.volume = volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Audio withVolume(Integer volume)
|
|
||||||
{
|
|
||||||
this.volume = volume;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("Audio [volume=");
|
|
||||||
builder.append(volume);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class AudioUpdateResult
|
|
||||||
{
|
|
||||||
private Success success;
|
|
||||||
|
|
||||||
public Success getSuccess()
|
|
||||||
{
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSuccess(Success success)
|
|
||||||
{
|
|
||||||
this.success = success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AudioUpdateResult withSuccess(Success success)
|
|
||||||
{
|
|
||||||
this.success = success;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Success
|
|
||||||
{
|
|
||||||
private Audio data;
|
|
||||||
|
|
||||||
public Audio getData()
|
|
||||||
{
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(Audio data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Success withData(Audio data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class BluetoothUpdateResult
|
|
||||||
{
|
|
||||||
private Success success;
|
|
||||||
|
|
||||||
public Success getSuccess()
|
|
||||||
{
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSuccess(Success success)
|
|
||||||
{
|
|
||||||
this.success = success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BluetoothUpdateResult withSuccess(Success success)
|
|
||||||
{
|
|
||||||
this.success = success;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Success
|
|
||||||
{
|
|
||||||
private Bluetooth data;
|
|
||||||
|
|
||||||
public Bluetooth getData()
|
|
||||||
{
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(Bluetooth data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Success withData(Bluetooth data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class BooleanParameter extends Parameter
|
|
||||||
{
|
|
||||||
private Boolean value;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BooleanParameter withName(String name)
|
|
||||||
{
|
|
||||||
super.withName(name);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BooleanParameter withRequired(Boolean required)
|
|
||||||
{
|
|
||||||
super.withRequired(required);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getValue()
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(Boolean value)
|
|
||||||
{
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BooleanParameter withValue(Boolean value)
|
|
||||||
{
|
|
||||||
setValue(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("BooleanParameter [value=");
|
|
||||||
builder.append(value);
|
|
||||||
builder.append(", getName()=");
|
|
||||||
builder.append(getName());
|
|
||||||
builder.append(", getRequired()=");
|
|
||||||
builder.append(getRequired());
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,142 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class Display
|
|
||||||
{
|
|
||||||
private Integer brightness;
|
|
||||||
private String brightnessMode;
|
|
||||||
private Integer height;
|
|
||||||
private Screensaver screensaver;
|
|
||||||
private String type;
|
|
||||||
private Integer width;
|
|
||||||
|
|
||||||
public Integer getBrightness()
|
|
||||||
{
|
|
||||||
return brightness;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBrightness(Integer brightness)
|
|
||||||
{
|
|
||||||
this.brightness = brightness;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Display withBrightness(Integer brightness)
|
|
||||||
{
|
|
||||||
this.brightness = brightness;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBrightnessMode()
|
|
||||||
{
|
|
||||||
return brightnessMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBrightnessMode(String brightnessMode)
|
|
||||||
{
|
|
||||||
this.brightnessMode = brightnessMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Display withBrightnessMode(String brightnessMode)
|
|
||||||
{
|
|
||||||
this.brightnessMode = brightnessMode;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getHeight()
|
|
||||||
{
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeight(Integer height)
|
|
||||||
{
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Display withHeight(Integer height)
|
|
||||||
{
|
|
||||||
this.height = height;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Screensaver getScreensaver()
|
|
||||||
{
|
|
||||||
return screensaver;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setScreensaver(Screensaver screensaver)
|
|
||||||
{
|
|
||||||
this.screensaver = screensaver;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Display withScreensaver(Screensaver screensaver)
|
|
||||||
{
|
|
||||||
this.screensaver = screensaver;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType()
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Display withType(String type)
|
|
||||||
{
|
|
||||||
this.type = type;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getWidth()
|
|
||||||
{
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWidth(Integer width)
|
|
||||||
{
|
|
||||||
this.width = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Display withWidth(Integer width)
|
|
||||||
{
|
|
||||||
this.width = width;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("Display [brightness=");
|
|
||||||
builder.append(brightness);
|
|
||||||
builder.append(", brightnessMode=");
|
|
||||||
builder.append(brightnessMode);
|
|
||||||
builder.append(", height=");
|
|
||||||
builder.append(height);
|
|
||||||
builder.append(", screensaver=");
|
|
||||||
builder.append(screensaver);
|
|
||||||
builder.append(", type=");
|
|
||||||
builder.append(type);
|
|
||||||
builder.append(", width=");
|
|
||||||
builder.append(width);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class DisplayUpdateResult
|
|
||||||
{
|
|
||||||
private Success success;
|
|
||||||
|
|
||||||
public Success getSuccess()
|
|
||||||
{
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSuccess(Success success)
|
|
||||||
{
|
|
||||||
this.success = success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DisplayUpdateResult withSuccess(Success success)
|
|
||||||
{
|
|
||||||
this.success = success;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Success
|
|
||||||
{
|
|
||||||
private Display data;
|
|
||||||
|
|
||||||
public Display getData()
|
|
||||||
{
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(Display data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Success withData(Display data)
|
|
||||||
{
|
|
||||||
this.data = data;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class Error
|
|
||||||
{
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message)
|
|
||||||
{
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Error withMessage(String message)
|
|
||||||
{
|
|
||||||
this.message = message;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("Error [message=");
|
|
||||||
builder.append(message);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Failure
|
|
||||||
{
|
|
||||||
private List<Error> errors = new ArrayList<Error>();
|
|
||||||
|
|
||||||
public List<Error> getErrors()
|
|
||||||
{
|
|
||||||
return errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setErrors(List<Error> errors)
|
|
||||||
{
|
|
||||||
this.errors = errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Failure withErrors(List<Error> errors)
|
|
||||||
{
|
|
||||||
this.errors = errors;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("Failure [errors=");
|
|
||||||
builder.append(errors);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,179 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class GoalData
|
|
||||||
{
|
|
||||||
private Integer start;
|
|
||||||
private Integer current;
|
|
||||||
private Integer end;
|
|
||||||
private String unit;
|
|
||||||
|
|
||||||
public Integer getStart()
|
|
||||||
{
|
|
||||||
return start;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStart(Integer start)
|
|
||||||
{
|
|
||||||
this.start = start;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GoalData withStart(Integer start)
|
|
||||||
{
|
|
||||||
this.start = start;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getCurrent()
|
|
||||||
{
|
|
||||||
return current;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrent(Integer current)
|
|
||||||
{
|
|
||||||
this.current = current;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GoalData withCurrent(Integer current)
|
|
||||||
{
|
|
||||||
this.current = current;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getEnd()
|
|
||||||
{
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnd(Integer end)
|
|
||||||
{
|
|
||||||
this.end = end;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GoalData withEnd(Integer end)
|
|
||||||
{
|
|
||||||
this.end = end;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUnit()
|
|
||||||
{
|
|
||||||
return unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnit(String unit)
|
|
||||||
{
|
|
||||||
this.unit = unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GoalData withUnit(String unit)
|
|
||||||
{
|
|
||||||
this.unit = unit;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
final int prime = 31;
|
|
||||||
int result = 1;
|
|
||||||
result = prime * result + ((current == null) ? 0 : current.hashCode());
|
|
||||||
result = prime * result + ((end == null) ? 0 : end.hashCode());
|
|
||||||
result = prime * result + ((start == null) ? 0 : start.hashCode());
|
|
||||||
result = prime * result + ((unit == null) ? 0 : unit.hashCode());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
if (this == obj)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
GoalData other = (GoalData)obj;
|
|
||||||
if (current == null)
|
|
||||||
{
|
|
||||||
if (other.current != null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!current.equals(other.current))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (end == null)
|
|
||||||
{
|
|
||||||
if (other.end != null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!end.equals(other.end))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (start == null)
|
|
||||||
{
|
|
||||||
if (other.start != null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!start.equals(other.start))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (unit == null)
|
|
||||||
{
|
|
||||||
if (other.unit != null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!unit.equals(other.unit))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("GoalData [start=");
|
|
||||||
builder.append(start);
|
|
||||||
builder.append(", current=");
|
|
||||||
builder.append(current);
|
|
||||||
builder.append(", end=");
|
|
||||||
builder.append(end);
|
|
||||||
builder.append(", unit=");
|
|
||||||
builder.append(unit);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class IntegerParameter extends Parameter
|
|
||||||
{
|
|
||||||
private Integer value;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IntegerParameter withName(String name)
|
|
||||||
{
|
|
||||||
super.withName(name);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IntegerParameter withRequired(Boolean required)
|
|
||||||
{
|
|
||||||
super.withRequired(required);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getValue()
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(Integer value)
|
|
||||||
{
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntegerParameter withValue(Integer value)
|
|
||||||
{
|
|
||||||
setValue(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("IntegerParameter [value=");
|
|
||||||
builder.append(value);
|
|
||||||
builder.append(", getName()=");
|
|
||||||
builder.append(getName());
|
|
||||||
builder.append(", getRequired()=");
|
|
||||||
builder.append(getRequired());
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class Modes
|
|
||||||
{
|
|
||||||
private TimeBased timeBased;
|
|
||||||
private WhenDark whenDark;
|
|
||||||
|
|
||||||
public TimeBased getTimeBased()
|
|
||||||
{
|
|
||||||
return timeBased;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimeBased(TimeBased timeBased)
|
|
||||||
{
|
|
||||||
this.timeBased = timeBased;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Modes withTimeBased(TimeBased timeBased)
|
|
||||||
{
|
|
||||||
this.timeBased = timeBased;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WhenDark getWhenDark()
|
|
||||||
{
|
|
||||||
return whenDark;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWhenDark(WhenDark whenDark)
|
|
||||||
{
|
|
||||||
this.whenDark = whenDark;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Modes withWhenDark(WhenDark whenDark)
|
|
||||||
{
|
|
||||||
this.whenDark = whenDark;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("Modes [timeBased=");
|
|
||||||
builder.append(timeBased);
|
|
||||||
builder.append(", whenDark=");
|
|
||||||
builder.append(whenDark);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,87 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NotificationModel
|
|
||||||
{
|
|
||||||
private Integer cycles;
|
|
||||||
private List<Frame> frames;
|
|
||||||
private Sound sound;
|
|
||||||
|
|
||||||
public Integer getCycles()
|
|
||||||
{
|
|
||||||
return cycles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCycles(Integer cycles)
|
|
||||||
{
|
|
||||||
this.cycles = cycles;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationModel withCycles(Integer cycles)
|
|
||||||
{
|
|
||||||
this.cycles = cycles;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Frame> getFrames()
|
|
||||||
{
|
|
||||||
return frames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFrames(List<Frame> frames)
|
|
||||||
{
|
|
||||||
this.frames = frames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationModel withFrames(List<Frame> frames)
|
|
||||||
{
|
|
||||||
this.frames = frames;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Sound getSound()
|
|
||||||
{
|
|
||||||
return sound;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSound(Sound sound)
|
|
||||||
{
|
|
||||||
this.sound = sound;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationModel withSound(Sound sound)
|
|
||||||
{
|
|
||||||
this.sound = sound;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("NotificationModel [cycles=");
|
|
||||||
builder.append(cycles);
|
|
||||||
builder.append(", frames=");
|
|
||||||
builder.append(frames);
|
|
||||||
builder.append(", sound=");
|
|
||||||
builder.append(sound);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class NotificationResult
|
|
||||||
{
|
|
||||||
private Success success;
|
|
||||||
|
|
||||||
public Success getSuccess()
|
|
||||||
{
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSuccess(Success success)
|
|
||||||
{
|
|
||||||
this.success = success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NotificationResult withSuccess(Success success)
|
|
||||||
{
|
|
||||||
this.success = success;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Success
|
|
||||||
{
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
public String getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Success withId(String id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public abstract class Parameter
|
|
||||||
{
|
|
||||||
private String name;
|
|
||||||
private Boolean required;
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Parameter withName(String name)
|
|
||||||
{
|
|
||||||
setName(name);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getRequired()
|
|
||||||
{
|
|
||||||
return required;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRequired(Boolean required)
|
|
||||||
{
|
|
||||||
this.required = required;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Parameter withRequired(Boolean required)
|
|
||||||
{
|
|
||||||
setRequired(required);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class Screensaver
|
|
||||||
{
|
|
||||||
private Boolean enabled;
|
|
||||||
private Modes modes;
|
|
||||||
private String widget;
|
|
||||||
|
|
||||||
public Boolean isEnabled()
|
|
||||||
{
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(Boolean enabled)
|
|
||||||
{
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Screensaver withEnabled(Boolean enabled)
|
|
||||||
{
|
|
||||||
this.enabled = enabled;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Modes getModes()
|
|
||||||
{
|
|
||||||
return modes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setModes(Modes modes)
|
|
||||||
{
|
|
||||||
this.modes = modes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Screensaver withModes(Modes modes)
|
|
||||||
{
|
|
||||||
this.modes = modes;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWidget()
|
|
||||||
{
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWidget(String widget)
|
|
||||||
{
|
|
||||||
this.widget = widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Screensaver withWidget(String widget)
|
|
||||||
{
|
|
||||||
this.widget = widget;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("Screensaver [enabled=");
|
|
||||||
builder.append(enabled);
|
|
||||||
builder.append(", modes=");
|
|
||||||
builder.append(modes);
|
|
||||||
builder.append(", widget=");
|
|
||||||
builder.append(widget);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class Sound
|
|
||||||
{
|
|
||||||
private String category;
|
|
||||||
private String id;
|
|
||||||
private Integer repeat;
|
|
||||||
|
|
||||||
public String getCategory()
|
|
||||||
{
|
|
||||||
return category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCategory(String category)
|
|
||||||
{
|
|
||||||
this.category = category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Sound withCategory(String category)
|
|
||||||
{
|
|
||||||
this.category = category;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Sound withId(String id)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getRepeat()
|
|
||||||
{
|
|
||||||
return repeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRepeat(Integer repeat)
|
|
||||||
{
|
|
||||||
this.repeat = repeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Sound withRepeat(Integer repeat)
|
|
||||||
{
|
|
||||||
this.repeat = repeat;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("Sound [category=");
|
|
||||||
builder.append(category);
|
|
||||||
builder.append(", id=");
|
|
||||||
builder.append(id);
|
|
||||||
builder.append(", repeat=");
|
|
||||||
builder.append(repeat);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class StringParameter extends Parameter
|
|
||||||
{
|
|
||||||
private String format;
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StringParameter withName(String name)
|
|
||||||
{
|
|
||||||
super.withName(name);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StringParameter withRequired(Boolean required)
|
|
||||||
{
|
|
||||||
super.withRequired(required);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFormat()
|
|
||||||
{
|
|
||||||
return format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFormat(String format)
|
|
||||||
{
|
|
||||||
this.format = format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringParameter withFormat(String format)
|
|
||||||
{
|
|
||||||
setFormat(format);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue()
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(String value)
|
|
||||||
{
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StringParameter withValue(String value)
|
|
||||||
{
|
|
||||||
setValue(value);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("StringParameter [format=");
|
|
||||||
builder.append(format);
|
|
||||||
builder.append(", value=");
|
|
||||||
builder.append(value);
|
|
||||||
builder.append(", getName()=");
|
|
||||||
builder.append(getName());
|
|
||||||
builder.append(", getRequired()=");
|
|
||||||
builder.append(getRequired());
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class TimeBased
|
|
||||||
{
|
|
||||||
private Boolean enabled;
|
|
||||||
|
|
||||||
public Boolean isEnabled()
|
|
||||||
{
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(Boolean enabled)
|
|
||||||
{
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimeBased withEnabled(Boolean enabled)
|
|
||||||
{
|
|
||||||
this.enabled = enabled;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("TimeBased [enabled=");
|
|
||||||
builder.append(enabled);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
import java.util.SortedMap;
|
|
||||||
|
|
||||||
public class UpdateAction extends Action
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public UpdateAction withId(String id)
|
|
||||||
{
|
|
||||||
super.setId(id);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UpdateAction withParameters(SortedMap<String, Parameter> parameters)
|
|
||||||
{
|
|
||||||
super.setParameters(parameters);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
public class WhenDark
|
|
||||||
{
|
|
||||||
private Boolean enabled;
|
|
||||||
|
|
||||||
public Boolean isEnabled()
|
|
||||||
{
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(Boolean enabled)
|
|
||||||
{
|
|
||||||
this.enabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WhenDark withEnabled(Boolean enabled)
|
|
||||||
{
|
|
||||||
this.enabled = enabled;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("WhenDark [enabled=");
|
|
||||||
builder.append(enabled);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class WidgetUpdates
|
|
||||||
{
|
|
||||||
private List<Frame> frames;
|
|
||||||
|
|
||||||
public List<Frame> getFrames()
|
|
||||||
{
|
|
||||||
return frames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFrames(List<Frame> frames)
|
|
||||||
{
|
|
||||||
this.frames = frames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WidgetUpdates withFrames(List<Frame> frames)
|
|
||||||
{
|
|
||||||
this.frames = frames;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
builder.append("WidgetUpdates [frames=");
|
|
||||||
builder.append(frames);
|
|
||||||
builder.append("]");
|
|
||||||
return builder.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model;
|
|
||||||
|
|
||||||
public interface ApiValue
|
|
||||||
{
|
|
||||||
public String toRaw();
|
|
||||||
|
|
||||||
public static String raw(ApiValue value)
|
|
||||||
{
|
|
||||||
if (value == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value.toRaw();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model;
|
|
||||||
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.SortedMap;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.BooleanParameter;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Parameter;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.StringParameter;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.UpdateAction;
|
|
||||||
|
|
||||||
public class ClockApp extends CoreApplication
|
|
||||||
{
|
|
||||||
private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss");
|
|
||||||
|
|
||||||
private static final String NAME = "com.lametric.clock";
|
|
||||||
|
|
||||||
private static final String ACTION_ALARM = "clock.alarm";
|
|
||||||
|
|
||||||
private static final String PARAMETER_ENABLED = "enabled";
|
|
||||||
private static final String PARAMETER_TIME = "time";
|
|
||||||
private static final String PARAMETER_WAKE_WITH_RADIO = "wake_with_radio";
|
|
||||||
|
|
||||||
public ClockApp()
|
|
||||||
{
|
|
||||||
super(NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction setAlarm(Boolean enabled, LocalTime time, Boolean wakeWithRadio)
|
|
||||||
{
|
|
||||||
SortedMap<String, Parameter> parameters = new TreeMap<>();
|
|
||||||
|
|
||||||
if (enabled != null)
|
|
||||||
{
|
|
||||||
parameters.put(PARAMETER_ENABLED, new BooleanParameter().withValue(enabled));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (time != null)
|
|
||||||
{
|
|
||||||
parameters.put(PARAMETER_TIME,
|
|
||||||
new StringParameter().withValue(time.format(TIME_FORMATTER)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wakeWithRadio != null)
|
|
||||||
{
|
|
||||||
parameters.put(PARAMETER_WAKE_WITH_RADIO,
|
|
||||||
new BooleanParameter().withValue(wakeWithRadio));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new CoreAction(this,
|
|
||||||
new UpdateAction().withId(ACTION_ALARM).withParameters(parameters));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction stopAlarm()
|
|
||||||
{
|
|
||||||
SortedMap<String, Parameter> parameters = new TreeMap<>();
|
|
||||||
parameters.put(PARAMETER_ENABLED, new BooleanParameter().withValue(false));
|
|
||||||
|
|
||||||
return new CoreAction(this,
|
|
||||||
new UpdateAction().withId(ACTION_ALARM).withParameters(parameters));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.UpdateAction;
|
|
||||||
|
|
||||||
public class CoreAction
|
|
||||||
{
|
|
||||||
private final CoreApplication app;
|
|
||||||
private final UpdateAction action;
|
|
||||||
|
|
||||||
protected CoreAction(CoreApplication app, UpdateAction action)
|
|
||||||
{
|
|
||||||
this.app = app;
|
|
||||||
this.action = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreApplication getApp()
|
|
||||||
{
|
|
||||||
return app;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UpdateAction getAction()
|
|
||||||
{
|
|
||||||
return action;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model;
|
|
||||||
|
|
||||||
public abstract class CoreApplication
|
|
||||||
{
|
|
||||||
private final String packageName;
|
|
||||||
|
|
||||||
public CoreApplication(String packageName)
|
|
||||||
{
|
|
||||||
this.packageName = packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPackageName()
|
|
||||||
{
|
|
||||||
return packageName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model;
|
|
||||||
|
|
||||||
public class CoreApps
|
|
||||||
{
|
|
||||||
private static final ClockApp CLOCK = new ClockApp();
|
|
||||||
private static final CountdownApp COUNTDOWN = new CountdownApp();
|
|
||||||
private static final RadioApp RADIO = new RadioApp();
|
|
||||||
private static final StopwatchApp STOPWATCH = new StopwatchApp();
|
|
||||||
private static final WeatherApp WEATHER = new WeatherApp();
|
|
||||||
|
|
||||||
public static ClockApp clock()
|
|
||||||
{
|
|
||||||
return CLOCK;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CountdownApp countdown()
|
|
||||||
{
|
|
||||||
return COUNTDOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RadioApp radio()
|
|
||||||
{
|
|
||||||
return RADIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static StopwatchApp stopwatch()
|
|
||||||
{
|
|
||||||
return STOPWATCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WeatherApp weather()
|
|
||||||
{
|
|
||||||
return WEATHER;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @formatter:off
|
|
||||||
private CoreApps() {}
|
|
||||||
// @formatter:on
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model;
|
|
||||||
|
|
||||||
import java.util.SortedMap;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.BooleanParameter;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.IntegerParameter;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.Parameter;
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.UpdateAction;
|
|
||||||
|
|
||||||
public class CountdownApp extends CoreApplication
|
|
||||||
{
|
|
||||||
private static final String NAME = "com.lametric.countdown";
|
|
||||||
|
|
||||||
private static final String ACTION_CONFIGURE = "countdown.configure";
|
|
||||||
private static final String ACTION_PAUSE = "countdown.pause";
|
|
||||||
private static final String ACTION_RESET = "countdown.reset";
|
|
||||||
private static final String ACTION_START = "countdown.start";
|
|
||||||
|
|
||||||
private static final String PARAMETER_DURATION = "duration";
|
|
||||||
private static final String PARAMETER_START_NOW = "start_now";
|
|
||||||
|
|
||||||
public CountdownApp()
|
|
||||||
{
|
|
||||||
super(NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction configure(int duration, boolean startNow)
|
|
||||||
{
|
|
||||||
SortedMap<String, Parameter> parameters = new TreeMap<>();
|
|
||||||
parameters.put(PARAMETER_DURATION, new IntegerParameter().withValue(duration));
|
|
||||||
parameters.put(PARAMETER_START_NOW, new BooleanParameter().withValue(startNow));
|
|
||||||
|
|
||||||
return new CoreAction(this,
|
|
||||||
new UpdateAction().withId(ACTION_CONFIGURE)
|
|
||||||
.withParameters(parameters));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction pause()
|
|
||||||
{
|
|
||||||
return new CoreAction(this, new UpdateAction().withId(ACTION_PAUSE));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction reset()
|
|
||||||
{
|
|
||||||
return new CoreAction(this, new UpdateAction().withId(ACTION_RESET));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction start()
|
|
||||||
{
|
|
||||||
return new CoreAction(this, new UpdateAction().withId(ACTION_START));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model;
|
|
||||||
|
|
||||||
public interface Icon extends ApiValue
|
|
||||||
{
|
|
||||||
// marker interface
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.UpdateAction;
|
|
||||||
|
|
||||||
public class RadioApp extends CoreApplication
|
|
||||||
{
|
|
||||||
private static final String NAME = "com.lametric.radio";
|
|
||||||
|
|
||||||
private static final String ACTION_NEXT = "radio.next";
|
|
||||||
private static final String ACTION_PLAY = "radio.play";
|
|
||||||
private static final String ACTION_PREV = "radio.prev";
|
|
||||||
private static final String ACTION_STOP = "radio.stop";
|
|
||||||
|
|
||||||
public RadioApp()
|
|
||||||
{
|
|
||||||
super(NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction next()
|
|
||||||
{
|
|
||||||
return new CoreAction(this, new UpdateAction().withId(ACTION_NEXT));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction play()
|
|
||||||
{
|
|
||||||
return new CoreAction(this, new UpdateAction().withId(ACTION_PLAY));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction previous()
|
|
||||||
{
|
|
||||||
return new CoreAction(this, new UpdateAction().withId(ACTION_PREV));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction stop()
|
|
||||||
{
|
|
||||||
return new CoreAction(this, new UpdateAction().withId(ACTION_STOP));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.UpdateAction;
|
|
||||||
|
|
||||||
public class StopwatchApp extends CoreApplication
|
|
||||||
{
|
|
||||||
private static final String NAME = "com.lametric.stopwatch";
|
|
||||||
|
|
||||||
private static final String ACTION_PAUSE = "stopwatch.pause";
|
|
||||||
private static final String ACTION_RESET = "stopwatch.reset";
|
|
||||||
private static final String ACTION_START = "stopwatch.start";
|
|
||||||
|
|
||||||
public StopwatchApp()
|
|
||||||
{
|
|
||||||
super(NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction pause()
|
|
||||||
{
|
|
||||||
return new CoreAction(this, new UpdateAction().withId(ACTION_PAUSE));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction reset()
|
|
||||||
{
|
|
||||||
return new CoreAction(this, new UpdateAction().withId(ACTION_RESET));
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction start()
|
|
||||||
{
|
|
||||||
return new CoreAction(this, new UpdateAction().withId(ACTION_START));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.local.model.UpdateAction;
|
|
||||||
|
|
||||||
public class WeatherApp extends CoreApplication
|
|
||||||
{
|
|
||||||
private static final String NAME = "com.lametric.weather";
|
|
||||||
|
|
||||||
private static final String ACTION_FORECAST = "weather.forecast";
|
|
||||||
|
|
||||||
public WeatherApp()
|
|
||||||
{
|
|
||||||
super(NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreAction forecast()
|
|
||||||
{
|
|
||||||
return new CoreAction(this, new UpdateAction().withId(ACTION_FORECAST));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model.enums;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.model.ApiValue;
|
|
||||||
|
|
||||||
public enum BrightnessMode implements ApiValue
|
|
||||||
{
|
|
||||||
AUTO,
|
|
||||||
MANUAL;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toRaw()
|
|
||||||
{
|
|
||||||
return name().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BrightnessMode toEnum(String raw)
|
|
||||||
{
|
|
||||||
if (raw == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return valueOf(raw.toUpperCase());
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
// not a valid raw string
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model.enums;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.model.ApiValue;
|
|
||||||
|
|
||||||
public enum DisplayType implements ApiValue
|
|
||||||
{
|
|
||||||
MONOCHROME,
|
|
||||||
GRAYSCALE,
|
|
||||||
COLOR,
|
|
||||||
MIXED;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toRaw()
|
|
||||||
{
|
|
||||||
return name().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DisplayType toEnum(String raw)
|
|
||||||
{
|
|
||||||
if (raw == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return valueOf(raw.toUpperCase());
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
// not a valid raw string
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model.enums;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.model.ApiValue;
|
|
||||||
|
|
||||||
public enum IconType implements ApiValue
|
|
||||||
{
|
|
||||||
NONE,
|
|
||||||
INFO,
|
|
||||||
ALERT;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toRaw()
|
|
||||||
{
|
|
||||||
return name().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IconType toEnum(String raw)
|
|
||||||
{
|
|
||||||
if (raw == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return valueOf(raw.toUpperCase());
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
// not a valid raw string
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model.enums;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.model.ApiValue;
|
|
||||||
|
|
||||||
public enum IpMode implements ApiValue
|
|
||||||
{
|
|
||||||
STATIC,
|
|
||||||
DHCP;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toRaw()
|
|
||||||
{
|
|
||||||
return name().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IpMode toEnum(String raw)
|
|
||||||
{
|
|
||||||
if (raw == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return valueOf(raw.toUpperCase());
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
// not a valid raw string
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model.enums;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.model.ApiValue;
|
|
||||||
|
|
||||||
public enum Priority implements ApiValue
|
|
||||||
{
|
|
||||||
INFO,
|
|
||||||
WARNING,
|
|
||||||
CRITICAL;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toRaw()
|
|
||||||
{
|
|
||||||
return name().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Priority toEnum(String raw)
|
|
||||||
{
|
|
||||||
if (raw == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return valueOf(raw.toUpperCase());
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
// not a valid raw string
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model.enums;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.model.ApiValue;
|
|
||||||
|
|
||||||
public enum SoundCategory implements ApiValue
|
|
||||||
{
|
|
||||||
NOTIFICATIONS,
|
|
||||||
ALARMS;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toRaw()
|
|
||||||
{
|
|
||||||
return name().toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SoundCategory toEnum(String raw)
|
|
||||||
{
|
|
||||||
if (raw == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return valueOf(raw.toUpperCase());
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
// not a valid raw string
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model.enums;
|
|
||||||
|
|
||||||
import org.openhab.binding.lametrictime.api.model.ApiValue;
|
|
||||||
|
|
||||||
public enum WifiEncryption implements ApiValue
|
|
||||||
{
|
|
||||||
OPEN,
|
|
||||||
WEP,
|
|
||||||
WPA,
|
|
||||||
WPA2;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toRaw()
|
|
||||||
{
|
|
||||||
return name();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WifiEncryption toEnum(String raw)
|
|
||||||
{
|
|
||||||
if (raw == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return valueOf(raw);
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
// not a valid raw string
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -37,7 +37,7 @@
|
|||||||
* only if the new code is made subject to such option by the copyright
|
* only if the new code is made subject to such option by the copyright
|
||||||
* holder.
|
* holder.
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.lametrictime.api.authentication;
|
package org.openhab.binding.lametrictime.internal.api.authentication;
|
||||||
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
|
@ -37,7 +37,7 @@
|
|||||||
* only if the new code is made subject to such option by the copyright
|
* only if the new code is made subject to such option by the copyright
|
||||||
* holder.
|
* holder.
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.lametrictime.api.authentication;
|
package org.openhab.binding.lametrictime.internal.api.authentication;
|
||||||
|
|
||||||
import javax.ws.rs.core.Feature;
|
import javax.ws.rs.core.Feature;
|
||||||
import javax.ws.rs.core.FeatureContext;
|
import javax.ws.rs.core.FeatureContext;
|
@ -37,8 +37,7 @@
|
|||||||
* only if the new code is made subject to such option by the copyright
|
* only if the new code is made subject to such option by the copyright
|
||||||
* holder.
|
* holder.
|
||||||
*/
|
*/
|
||||||
|
package org.openhab.binding.lametrictime.internal.api.authentication;
|
||||||
package org.openhab.binding.lametrictime.api.authentication;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
@ -37,7 +37,7 @@
|
|||||||
* only if the new code is made subject to such option by the copyright
|
* only if the new code is made subject to such option by the copyright
|
||||||
* holder.
|
* holder.
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.lametrictime.api.authentication;
|
package org.openhab.binding.lametrictime.internal.api.authentication;
|
||||||
|
|
||||||
import javax.ws.rs.ProcessingException;
|
import javax.ws.rs.ProcessingException;
|
||||||
|
|
@ -37,7 +37,7 @@
|
|||||||
* only if the new code is made subject to such option by the copyright
|
* only if the new code is made subject to such option by the copyright
|
||||||
* holder.
|
* holder.
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.lametrictime.api.authentication;
|
package org.openhab.binding.lametrictime.internal.api.authentication;
|
||||||
|
|
||||||
import javax.ws.rs.client.ResponseProcessingException;
|
import javax.ws.rs.client.ResponseProcessingException;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
@ -37,7 +37,7 @@
|
|||||||
* only if the new code is made subject to such option by the copyright
|
* only if the new code is made subject to such option by the copyright
|
||||||
* holder.
|
* holder.
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.lametrictime.api.filter;
|
package org.openhab.binding.lametrictime.internal.api.filter;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api;
|
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import com.googlecode.junittoolbox.SuiteClasses;
|
|
||||||
import com.googlecode.junittoolbox.WildcardPatternSuite;
|
|
||||||
|
|
||||||
@RunWith(WildcardPatternSuite.class)
|
|
||||||
@SuiteClasses({ "**/*IT.class" })
|
|
||||||
public class AllIntegrationTestsSuite
|
|
||||||
{
|
|
||||||
// Execute all integration tests
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api;
|
|
||||||
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import com.googlecode.junittoolbox.ParallelSuite;
|
|
||||||
import com.googlecode.junittoolbox.SuiteClasses;
|
|
||||||
|
|
||||||
@RunWith(ParallelSuite.class)
|
|
||||||
@SuiteClasses({ "**/*Test.class" })
|
|
||||||
public class AllUnitTestsSuite {
|
|
||||||
// Execute all unit tests
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.impl;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.openhab.binding.lametrictime.api.test.AbstractTest;
|
|
||||||
|
|
||||||
public class FileIconTest extends AbstractTest
|
|
||||||
{
|
|
||||||
@Test
|
|
||||||
public void testLocalPathGif()
|
|
||||||
{
|
|
||||||
FileIcon icon = new FileIcon(getTestDataPath("smile.gif"));
|
|
||||||
assertEquals("data:image/gif;base64,R0lGODlhCAAIAPEAAPz+BPz+/AAAAAAAACH5BAkKAAIAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAACAAIAAACEZSAYJfIElREIdaGs3PPNFMAACH5BAkKAAIALAAAAAAIAAgAAAIRlIBgl8gSVEQh1oazU4szJxQAIfkECTIAAgAsAAAAAAgACAAAAhKUgGCXyBJURCHWhlU7fCmzCQUAIfkECRQAAgAsAAAAAAgACAAAAhGUgGCXyBIaClFa1Y5eymRRAAAh+QQJMgACACwAAAAACAAIAAACEpSAYJfIElREIdaGVTt8KbMJBQA7",
|
|
||||||
icon.toRaw());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLocalPathPng()
|
|
||||||
{
|
|
||||||
FileIcon icon = new FileIcon(getTestDataPath("info.png"));
|
|
||||||
assertEquals("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAL0lEQVQYlWN0NPv3nwEPYIEx9p1kRJFwMofoY0IXQGczMRAAVFSA7EhkNiMhbwIAA/sN+bH1CpgAAAAASUVORK5CYII=",
|
|
||||||
icon.toRaw());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLocalFileGif()
|
|
||||||
{
|
|
||||||
FileIcon icon = new FileIcon(getTestDataFile("smile.gif"));
|
|
||||||
assertEquals("data:image/gif;base64,R0lGODlhCAAIAPEAAPz+BPz+/AAAAAAAACH5BAkKAAIAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAACAAIAAACEZSAYJfIElREIdaGs3PPNFMAACH5BAkKAAIALAAAAAAIAAgAAAIRlIBgl8gSVEQh1oazU4szJxQAIfkECTIAAgAsAAAAAAgACAAAAhKUgGCXyBJURCHWhlU7fCmzCQUAIfkECRQAAgAsAAAAAAgACAAAAhGUgGCXyBIaClFa1Y5eymRRAAAh+QQJMgACACwAAAAACAAIAAACEpSAYJfIElREIdaGVTt8KbMJBQA7",
|
|
||||||
icon.toRaw());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLocalFilePng()
|
|
||||||
{
|
|
||||||
FileIcon icon = new FileIcon(getTestDataFile("info.png"));
|
|
||||||
assertEquals("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAL0lEQVQYlWN0NPv3nwEPYIEx9p1kRJFwMofoY0IXQGczMRAAVFSA7EhkNiMhbwIAA/sN+bH1CpgAAAAASUVORK5CYII=",
|
|
||||||
icon.toRaw());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
import java.io.FileReader;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
|
|
||||||
import org.openhab.binding.lametrictime.api.test.AbstractTest;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
|
|
||||||
public class AudioTest extends AbstractTest
|
|
||||||
{
|
|
||||||
private static Gson gson;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void setUpBeforeClass()
|
|
||||||
{
|
|
||||||
gson = GsonGenerator.create(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSerializeAllFields() throws Exception
|
|
||||||
{
|
|
||||||
Audio audio = new Audio().withVolume(42);
|
|
||||||
assertEquals(readJson("audio.json"), gson.toJson(audio));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeserializeAllFields() throws Exception
|
|
||||||
{
|
|
||||||
try (FileReader reader = new FileReader(getTestDataFile("audio.json")))
|
|
||||||
{
|
|
||||||
Audio audio = gson.fromJson(reader, Audio.class);
|
|
||||||
assertEquals(Integer.valueOf(42), audio.getVolume());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
import java.io.FileReader;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
|
|
||||||
import org.openhab.binding.lametrictime.api.test.AbstractTest;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
|
|
||||||
public class BluetoothTest extends AbstractTest
|
|
||||||
{
|
|
||||||
private static Gson gson;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void setUpBeforeClass()
|
|
||||||
{
|
|
||||||
gson = GsonGenerator.create(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSerializeAllFields() throws Exception
|
|
||||||
{
|
|
||||||
Bluetooth bluetooth = new Bluetooth().withActive(false)
|
|
||||||
.withAvailable(true)
|
|
||||||
.withDiscoverable(false)
|
|
||||||
.withMac("AA:AA:AA:AA:AA:AA")
|
|
||||||
.withName("LM9999")
|
|
||||||
.withPairable(true);
|
|
||||||
assertEquals(readJson("bluetooth-mac-address.json"), gson.toJson(bluetooth));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeserializeMac() throws Exception
|
|
||||||
{
|
|
||||||
try (FileReader reader = new FileReader(getTestDataFile("bluetooth-mac.json")))
|
|
||||||
{
|
|
||||||
Bluetooth bluetooth = gson.fromJson(reader, Bluetooth.class);
|
|
||||||
assertEquals(false, bluetooth.isActive());
|
|
||||||
assertEquals(true, bluetooth.isAvailable());
|
|
||||||
assertEquals(false, bluetooth.isDiscoverable());
|
|
||||||
assertEquals("AA:AA:AA:AA:AA:AA", bluetooth.getMac());
|
|
||||||
assertEquals("LM9999", bluetooth.getName());
|
|
||||||
assertEquals(true, bluetooth.isPairable());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeserializeAddress() throws Exception
|
|
||||||
{
|
|
||||||
try (FileReader reader = new FileReader(getTestDataFile("bluetooth-address.json")))
|
|
||||||
{
|
|
||||||
Bluetooth bluetooth = gson.fromJson(reader, Bluetooth.class);
|
|
||||||
assertEquals(false, bluetooth.isActive());
|
|
||||||
assertEquals(true, bluetooth.isAvailable());
|
|
||||||
assertEquals(false, bluetooth.isDiscoverable());
|
|
||||||
assertEquals("AA:AA:AA:AA:AA:AA", bluetooth.getMac());
|
|
||||||
assertEquals("LM9999", bluetooth.getName());
|
|
||||||
assertEquals(true, bluetooth.isPairable());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
import java.io.FileReader;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
|
|
||||||
import org.openhab.binding.lametrictime.api.test.AbstractTest;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
|
|
||||||
public class GoalDataTest extends AbstractTest
|
|
||||||
{
|
|
||||||
private static Gson gson;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void setUpBeforeClass()
|
|
||||||
{
|
|
||||||
gson = GsonGenerator.create(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSerializeSimple() throws Exception
|
|
||||||
{
|
|
||||||
GoalData goalData = new GoalData().withStart(0).withEnd(100).withCurrent(50).withUnit("%");
|
|
||||||
assertEquals(readJson("goal-data.json"), gson.toJson(goalData));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeserializeSimple() throws Exception
|
|
||||||
{
|
|
||||||
try (FileReader reader = new FileReader(getTestDataFile("goal-data.json")))
|
|
||||||
{
|
|
||||||
GoalData goalData = gson.fromJson(reader, GoalData.class);
|
|
||||||
assertEquals(Integer.valueOf(0), goalData.getStart());
|
|
||||||
assertEquals(Integer.valueOf(100), goalData.getEnd());
|
|
||||||
assertEquals(Integer.valueOf(50), goalData.getCurrent());
|
|
||||||
assertEquals("%", goalData.getUnit());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.local.model;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
|
|
||||||
import org.openhab.binding.lametrictime.api.test.AbstractTest;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonPrimitive;
|
|
||||||
|
|
||||||
public class WidgetTest extends AbstractTest
|
|
||||||
{
|
|
||||||
private static Gson gson;
|
|
||||||
|
|
||||||
@BeforeAll
|
|
||||||
public static void setUpBeforeClass()
|
|
||||||
{
|
|
||||||
gson = GsonGenerator.create(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public void testSerialize() throws Exception
|
|
||||||
{
|
|
||||||
Widget widget = new Widget().withPackageName("com.lametric.radio")
|
|
||||||
.withIndex(Integer.valueOf(-1))
|
|
||||||
.withSettings(new HashMap<String, JsonPrimitive>()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
put("_title", new JsonPrimitive("Radio"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
assertEquals(readJson("widget.json"), gson.toJson(widget));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public void testDeserialize() throws Exception
|
|
||||||
{
|
|
||||||
try (FileReader reader = new FileReader(getTestDataFile("widget.json")))
|
|
||||||
{
|
|
||||||
Widget widget = gson.fromJson(reader, Widget.class);
|
|
||||||
assertEquals("com.lametric.radio", widget.getPackageName());
|
|
||||||
assertEquals(Integer.valueOf(-1), widget.getIndex());
|
|
||||||
assertEquals(new HashMap<String, JsonPrimitive>()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
put("_title", new JsonPrimitive("Radio"));
|
|
||||||
}
|
|
||||||
}, widget.getSettings());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model.enums;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
public class BrightnessModeTest {
|
|
||||||
@Test
|
|
||||||
public void testConversion() {
|
|
||||||
for (BrightnessMode value : BrightnessMode.values()) {
|
|
||||||
assertEquals(value, BrightnessMode.toEnum(value.toRaw()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testInvalidRawValue() {
|
|
||||||
assertNull(BrightnessMode.toEnum("invalid raw value"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNullRawValue() {
|
|
||||||
assertNull(BrightnessMode.toEnum(null));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2017-2018 Gregory Moyer and contributors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.openhab.binding.lametrictime.api.model.enums;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
public class DisplayTypeTest {
|
|
||||||
@Test
|
|
||||||
public void testConversion() {
|
|
||||||
for (DisplayType value : DisplayType.values()) {
|
|
||||||
assertEquals(value, DisplayType.toEnum(value.toRaw()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testInvalidRawValue() {
|
|
||||||
assertNull(DisplayType.toEnum("invalid raw value"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNullRawValue() {
|
|
||||||
assertNull(DisplayType.toEnum(null));
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user