Skip to content

Commit 3a91fd5

Browse files
authored
Merge pull request #2 from biczomate/checkstyle
Checkstyle
2 parents e69c577 + c459c8f commit 3a91fd5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+964
-449
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Continuous Integration
22

3-
on: [push]
3+
on: [ push ]
44

55
jobs:
66
build:

README.md

Lines changed: 59 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,19 @@ ikea-tradfri-api is a Java library for communicating with IKEA TRÅDFRI devices.
88

99
## Features
1010

11-
- Register a new client to the IKEA TRÅDFRI gateway
12-
- Get a list of all devices connected to the IKEA TRÅDFRI gateway
13-
- Get the current state of a light
14-
- Change the state of a light (on / off, brightness, colour, etc.)
15-
- Get the current state of a plug
16-
- Change the state of a plug (on / off)
17-
- Events to automatically detect changes for devices
18-
- Support for RGB colours for lights
19-
20-
11+
- Register a new client to the IKEA TRÅDFRI gateway
12+
- Get a list of all devices connected to the IKEA TRÅDFRI gateway
13+
- Get the current state of a light
14+
- Change the state of a light (on / off, brightness, colour, etc.)
15+
- Get the current state of a plug
16+
- Change the state of a plug (on / off)
17+
- Events to automatically detect changes for devices
18+
- Support for RGB colours for lights
2119

2220
## Installation
2321

24-
If possible, always try to use the latest version of this library for your application. The latest version can be found on the Maven Central repository and on the GitHub Releases page.
25-
26-
22+
If possible, always try to use the latest version of this library for your application. The latest version can be found
23+
on the Maven Central repository and on the GitHub Releases page.
2724

2825
### Maven
2926

@@ -37,8 +34,6 @@ To install this library using Maven, add the following dependency to your POM fi
3734
</dependency>
3835
```
3936

40-
41-
4237
### Gradle
4338

4439
To install this library using Gradle, add the following dependency to your build file:
@@ -47,40 +42,38 @@ To install this library using Gradle, add the following dependency to your build
4742
implementation 'nl.stijngroenen.tradfri:ikea-tradfri-api:1.2.0'
4843
```
4944

50-
51-
5245
### JAR
5346

54-
If you are not using a dependency management system (like Maven or Gradle), you could also add the standalone JAR file to your classpath. The JAR file can be downloaded from the Maven Central repository or from the GitHub Releases page. Make sure to also add the [dependencies](#built-with) to your classpath.
55-
56-
47+
If you are not using a dependency management system (like Maven or Gradle), you could also add the standalone JAR file
48+
to your classpath. The JAR file can be downloaded from the Maven Central repository or from the GitHub Releases page.
49+
Make sure to also add the [dependencies](#built-with) to your classpath.
5750

5851
## How To Use
5952

6053
### Connect to an IKEA TRÅDFRI gateway for the first time
6154

6255
Import the Gateway class and the Credentials class:
56+
6357
```Java
6458
import nl.stijngroenen.tradfri.device.Gateway;
6559
import nl.stijngroenen.tradfri.util.Credentials;
6660
```
6761

6862
Replace 'IP_OF_THE_GATEWAY' with the IP-address of the IKEA TRÅDFRI gateway.
69-
Replace 'SECURITY_CODE' with the security code of the IKEA TRÅDFRI gateway. The security code can be found on the bottom of the IKEA TRÅDFRI gateway.
63+
Replace 'SECURITY_CODE' with the security code of the IKEA TRÅDFRI gateway. The security code can be found on the bottom
64+
of the IKEA TRÅDFRI gateway.
7065

7166
The connect function returns credentials. These credentials can later be to to connect to the gateway again.
7267
Please store these credentials (identity and key) securely.
7368
The credentials expire after 6 weeks of inactivity.
7469

7570
```Java
76-
Gateway gateway = new Gateway("IP_OF_THE_GATEWAY");
77-
Credentials credentials = gateway.connect("SECURITY_CODE");
78-
String identity = credentials.getIdentity();
79-
String key = credentials.getKey();
71+
Gateway gateway=new Gateway("IP_OF_THE_GATEWAY");
72+
Credentials credentials=gateway.connect("SECURITY_CODE");
73+
String identity=credentials.getIdentity();
74+
String key=credentials.getKey();
8075
```
8176

82-
83-
8477
### Connect to an IKEA TRÅDFRI gateway using credentials
8578

8679
Import the Gateway class and the Credentials class:
@@ -94,13 +87,11 @@ Replace 'IP_OF_THE_GATEWAY' with the IP-address of the IKEA TRÅDFRI gateway.
9487
Replace 'IDENTITY' and 'KEY' with the identity and key returned when connecting for the first time.
9588

9689
```Java
97-
Gateway gateway = new Gateway("IP_OF_THE_GATEWAY");
98-
Credentials credentials = new Credentials("IDENTITY", "KEY");
99-
gateway.connect(credentials);
90+
Gateway gateway=new Gateway("IP_OF_THE_GATEWAY");
91+
Credentials credentials=new Credentials("IDENTITY","KEY");
92+
gateway.connect(credentials);
10093
```
10194

102-
103-
10495
### Get a list of all devices connected to the IKEA TRÅDFRI gateway
10596

10697
Import the Device class:
@@ -115,8 +106,6 @@ Get all devices connected to the IKEA TRÅDFRI gateway:
115106
Device[] devices = gateway.getDevices();
116107
```
117108

118-
119-
120109
### Get a device by id
121110

122111
Import the Device class:
@@ -132,8 +121,6 @@ Replace 'ID' with the id of the device.
132121
Device device = gateway.getDevice(ID);
133122
```
134123

135-
136-
137124
### Working with lights
138125

139126
#### Change a property of a light
@@ -149,15 +136,13 @@ Change a property of a light:
149136
Replace 'ID' with the id of the light.
150137

151138
```Java
152-
Device device = gateway.getDevice(ID);
153-
if(device.isLight()){
154-
Light light = device.toLight();
139+
Device device=gateway.getDevice(ID);
140+
if(device.isLight()){
141+
Light light=device.toLight();
155142
light.setBrightness(128);
156-
}
143+
}
157144
```
158145

159-
160-
161146
#### Change multiple properties of a light
162147

163148
Import the Device class and the Light class:
@@ -172,18 +157,16 @@ Change a property of a light:
172157
Replace 'ID' with the id of the light.
173158

174159
```Java
175-
Device device = gateway.getDevice(ID);
176-
if(device.isLight()){
177-
Light light = device.toLight();
160+
Device device=gateway.getDevice(ID);
161+
if(device.isLight()){
162+
Light light=device.toLight();
178163
light.updateOn(true);
179164
light.updateBrightness(128);
180165
light.updateColourHex(ColourHex.BLUE);
181166
light.applyUpdates();
182-
}
167+
}
183168
```
184169

185-
186-
187170
#### Turn on all the lights
188171

189172
Import the Device class and the Light class:
@@ -196,17 +179,15 @@ import nl.stijngroenen.tradfri.device.Light;
196179
Turn on all the lights:
197180

198181
```Java
199-
Device[] devices = gateway.getDevices();
200-
for(Device device: devices){
182+
Device[]devices=gateway.getDevices();
183+
for(Device device:devices){
201184
if(device.isLight()){
202-
Light light = device.toLight();
203-
light.setOn(true);
185+
Light light=device.toLight();
186+
light.setOn(true);
187+
}
204188
}
205-
}
206189
```
207190

208-
209-
210191
### Working with plugs
211192

212193
#### Turn on a plug
@@ -222,15 +203,13 @@ Turn on a plug:
222203
Replace 'ID' with the id of the plug.
223204

224205
```Java
225-
Device device = gateway.getDevice(ID);
226-
if(device.isPlug()){
227-
Plug plug = device.toPlug();
206+
Device device=gateway.getDevice(ID);
207+
if(device.isPlug()){
208+
Plug plug=device.toPlug();
228209
plug.setOn(true);
229-
}
210+
}
230211
```
231212

232-
233-
234213
### Working with events
235214

236215
#### Available events
@@ -256,8 +235,6 @@ if(device.isPlug()){
256235
| | PlugChangeEvent | The plug changed |
257236
| | PlugChangeOnEvent | The on / off state of the light changed |
258237

259-
260-
261238
#### Add an event handler to the IKEA TRÅDFRI gateway
262239

263240
Import the EventHandler class and the DeviceAddedEvent class:
@@ -270,18 +247,16 @@ import nl.stijngroenen.tradfri.device.event.DeviceAddedEvent;
270247
A new device is added to the IKEA TRÅDFRI gateway:
271248

272249
```Java
273-
EventHandler<DeviceAddedEvent> eventHandler = new EventHandler<DeviceAddedEvent>() {
274-
@Override
275-
public void handle(DeviceAddedEvent event){
276-
System.out.println("A new device is added: "+event.getDevice().getName());
250+
EventHandler<DeviceAddedEvent> eventHandler=new EventHandler<DeviceAddedEvent>(){
251+
@Override
252+
public void handle(DeviceAddedEvent event){
253+
System.out.println("A new device is added: "+event.getDevice().getName());
277254
}
278-
};
279-
gateway.enableObserve(); // This is necessary for the event handler to work.
280-
gateway.addEventHandler(eventHandler);
255+
};
256+
gateway.enableObserve(); // This is necessary for the event handler to work.
257+
gateway.addEventHandler(eventHandler);
281258
```
282259

283-
284-
285260
#### Add an event handler to a device
286261

287262
Import the Device class, the EventHandler class and the LightChangeOnEvent class:
@@ -296,40 +271,34 @@ Change a property of a light:
296271
Replace 'ID' with the id of the light.
297272

298273
```Java
299-
Device device = gateway.getDevice(ID);
300-
EventHandler<LightChangeOnEvent> eventHandler = new EventHandler<LightChangeOnEvent>() {
301-
@Override
302-
public void handle(LightChangeOnEvent event){
303-
System.out.println("The light is "+(event.getNewOn() ? "on" : "off"));
274+
Device device=gateway.getDevice(ID);
275+
EventHandler<LightChangeOnEvent> eventHandler=new EventHandler<LightChangeOnEvent>(){
276+
@Override
277+
public void handle(LightChangeOnEvent event){
278+
System.out.println("The light is "+(event.getNewOn()?"on":"off"));
304279
}
305-
};
306-
device.enableObserve(); // This is necessary for the event handler to work.
307-
device.addEventHandler(eventHandler);
280+
};
281+
device.enableObserve(); // This is necessary for the event handler to work.
282+
device.addEventHandler(eventHandler);
308283
```
309284

310-
311-
312285
## Built With
313286

314287
* [Californium](https://www.eclipse.org/californium/) - Library for the CoAP protocol
315288
* [Jackson Databind](https://github.com/FasterXML/jackson-databind) - Library for parsing and serializing JSON
316289
* [Maven](https://maven.apache.org/) - Dependency Management
317290

318-
319-
320291
## Versioning
321292

322-
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/StijnGroenen/ikea-tradfri-api/tags).
323-
324-
293+
We use [SemVer](http://semver.org/) for versioning. For the versions available, see
294+
the [tags on this repository](https://github.com/StijnGroenen/ikea-tradfri-api/tags).
325295

326296
## Authors
327297

328298
* **Stijn Groenen** - *Initial work* - [GitHub](https://github.com/StijnGroenen)
329299

330-
See also the list of [contributors](https://github.com/StijnGroenen/ikea-tradfri-api/contributors) who participated in this project.
331-
332-
300+
See also the list of [contributors](https://github.com/StijnGroenen/ikea-tradfri-api/contributors) who participated in
301+
this project.
333302

334303
## License
335304

checkstyle/checks_suppression.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE suppressions PUBLIC
3+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
4+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
5+
<suppressions>
6+
<suppress checks="SummaryJavadoc" files="."/>
7+
<suppress checks="EmptyCatchBlock" files="."/>
8+
</suppressions>

checkstyle/custom_checks.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
<module name="Checker">
6+
<module name="FileTabCharacter"/>
7+
<module name="LineLength">
8+
<property name="max" value="180"/>
9+
</module>
10+
<module name="TreeWalker">
11+
<module name="NeedBraces"/>
12+
<module name="OuterTypeFilename"/>
13+
<module name="NoLineWrap"/>
14+
<module name="Indentation">
15+
<property name="basicOffset" value="4"/>
16+
<property name="braceAdjustment" value="4"/>
17+
<property name="caseIndent" value="4"/>
18+
<property name="throwsIndent" value="4"/>
19+
<property name="lineWrappingIndentation" value="4"/>
20+
<property name="arrayInitIndent" value="4"/>
21+
</module>
22+
<module name="AvoidStarImport"/>
23+
<module name="CustomImportOrder">
24+
<property name="customImportOrderRules" value="STATIC###STANDARD_JAVA_PACKAGE###THIRD_PARTY_PACKAGE###"/>
25+
</module>
26+
<module name="MemberName">
27+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
28+
</module>
29+
<module name="LocalVariableName">
30+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
31+
</module>
32+
</module>
33+
</module>

0 commit comments

Comments
 (0)