Skip to content

Commit 1e9d187

Browse files
authored
Merge pull request #53 from timcharper/tharper/use-google-code-formatter
Format code automatically during compile using google-java-format
2 parents 3ec7264 + adf7af0 commit 1e9d187

File tree

195 files changed

+6753
-6825
lines changed

Some content is hidden

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

195 files changed

+6753
-6825
lines changed

pom.xml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@
116116

117117
<build>
118118
<plugins>
119+
<plugin>
120+
<groupId>com.coveo</groupId>
121+
<artifactId>fmt-maven-plugin</artifactId>
122+
<version>2.6.0</version>
123+
<executions>
124+
<execution>
125+
<goals>
126+
<goal>format</goal>
127+
</goals>
128+
</execution>
129+
</executions>
130+
</plugin>
119131
<plugin>
120132
<groupId>org.apache.maven.plugins</groupId>
121133
<artifactId>maven-compiler-plugin</artifactId>
@@ -272,19 +284,19 @@
272284
<profile>
273285
<id>ossrh</id>
274286
<properties>
275-
<gpg.executable>gpg</gpg.executable>
276-
<gpg.keyname>${env.GPG_KEYNAME}</gpg.keyname>
277-
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
278-
<gpg.defaultKeyring>false</gpg.defaultKeyring>
279-
<gpg.publicKeyring>deploy/pubring.gpg</gpg.publicKeyring>
280-
<gpg.secretKeyring>deploy/secring.gpg</gpg.secretKeyring>
281-
</properties>
287+
<gpg.executable>gpg</gpg.executable>
288+
<gpg.keyname>${env.GPG_KEYNAME}</gpg.keyname>
289+
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
290+
<gpg.defaultKeyring>false</gpg.defaultKeyring>
291+
<gpg.publicKeyring>deploy/pubring.gpg</gpg.publicKeyring>
292+
<gpg.secretKeyring>deploy/secring.gpg</gpg.secretKeyring>
293+
</properties>
282294
<activation>
283-
<property>
284-
<name>performRelease</name>
285-
<value>true</value>
286-
</property>
287-
</activation>
295+
<property>
296+
<name>performRelease</name>
297+
<value>true</value>
298+
</property>
299+
</activation>
288300
<build>
289301
<plugins>
290302
<plugin>

src/main/java/com/beowulfe/hap/HomekitAccessory.java

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,67 @@
33
import java.util.Collection;
44

55
/**
6-
* Base interface for all Homekit Accessories. You can implement this interface directly, but most users will
7-
* prefer to use the more full featured interfaces in {@link com.beowulfe.hap.accessories} which include a
8-
* default implementation of {@link #getServices()}.
9-
*
6+
* Base interface for all Homekit Accessories. You can implement this interface directly, but most
7+
* users will prefer to use the more full featured interfaces in {@link
8+
* com.beowulfe.hap.accessories} which include a default implementation of {@link #getServices()}.
9+
*
1010
* @author Andy Lintner
1111
*/
1212
public interface HomekitAccessory {
13-
14-
/**
15-
* A unique identifier that must remain static across invocations to prevent errors with paired iOS devices. When used
16-
* as a child of a Bridge, this value must be greater than 1, as that ID is reserved for the Bridge itself.
17-
*
18-
* @return the unique identifier.
19-
*/
20-
int getId();
2113

22-
/**
23-
* Returns a label to display in iOS.
24-
*
25-
* @return the label.
26-
*/
27-
String getLabel();
28-
29-
/**
30-
* Performs an operation that can be used to identify the accessory. This action can be performed without
31-
* pairing.
32-
*/
33-
void identify();
14+
/**
15+
* A unique identifier that must remain static across invocations to prevent errors with paired
16+
* iOS devices. When used as a child of a Bridge, this value must be greater than 1, as that ID is
17+
* reserved for the Bridge itself.
18+
*
19+
* @return the unique identifier.
20+
*/
21+
int getId();
3422

35-
/**
36-
* Returns a serial number to display in iOS.
37-
*
38-
* @return the serial number, or null.
39-
*/
40-
String getSerialNumber();
23+
/**
24+
* Returns a label to display in iOS.
25+
*
26+
* @return the label.
27+
*/
28+
String getLabel();
4129

42-
/**
43-
* Returns a model name to display in iOS.
44-
*
45-
* @return the model name, or null.
46-
*/
47-
String getModel();
30+
/**
31+
* Performs an operation that can be used to identify the accessory. This action can be performed
32+
* without pairing.
33+
*/
34+
void identify();
4835

49-
/**
50-
* Returns a manufacturer to display in iOS.
51-
*
52-
* @return the manufacturer, or null.
53-
*/
54-
String getManufacturer();
55-
56-
/**
57-
* The collection of Services this accessory supports. Services are the primary way to interact with the accessory via
58-
* Homekit. Besides the Services offered here, the accessory will automatically include the required information service.
59-
*
60-
* This method will only be useful if you're implementing your own accessory type. For the standard accessories, use
61-
* the default implementation provided by the interfaces in {@link com.beowulfe.hap.accessories}.
62-
*
63-
* @return the collection of services.
64-
*/
65-
Collection<Service> getServices();
36+
/**
37+
* Returns a serial number to display in iOS.
38+
*
39+
* @return the serial number, or null.
40+
*/
41+
String getSerialNumber();
42+
43+
/**
44+
* Returns a model name to display in iOS.
45+
*
46+
* @return the model name, or null.
47+
*/
48+
String getModel();
49+
50+
/**
51+
* Returns a manufacturer to display in iOS.
52+
*
53+
* @return the manufacturer, or null.
54+
*/
55+
String getManufacturer();
56+
57+
/**
58+
* The collection of Services this accessory supports. Services are the primary way to interact
59+
* with the accessory via Homekit. Besides the Services offered here, the accessory will
60+
* automatically include the required information service.
61+
*
62+
* <p>This method will only be useful if you're implementing your own accessory type. For the
63+
* standard accessories, use the default implementation provided by the interfaces in {@link
64+
* com.beowulfe.hap.accessories}.
65+
*
66+
* @return the collection of services.
67+
*/
68+
Collection<Service> getServices();
6669
}

src/main/java/com/beowulfe/hap/HomekitAuthInfo.java

Lines changed: 74 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,86 @@
33
import java.math.BigInteger;
44

55
/**
6-
* Authentication info that must be provided when constructing a new {@link HomekitServer}. You will need to implement
7-
* this interface yourself to provide the necessary callbacks to a persistent storage mechanism. All values provided
8-
* must be constant across invocations or the accessories will require re-pairing within iOS.
6+
* Authentication info that must be provided when constructing a new {@link HomekitServer}. You will
7+
* need to implement this interface yourself to provide the necessary callbacks to a persistent
8+
* storage mechanism. All values provided must be constant across invocations or the accessories
9+
* will require re-pairing within iOS.
910
*
1011
* @author Andy Lintner
1112
*/
1213
public interface HomekitAuthInfo {
1314

14-
/**
15-
* A pin code used for pairing the device. This pin will be required within iOS in order to complete pairing. The numbers
16-
* cannot be sequential and should not have a repeating pattern.
17-
*
18-
* @return the pin code, in the form ###-##-###
19-
*/
20-
String getPin();
21-
22-
/**
23-
* A unique MAC address to be advertised with the Homekit information. This does not have to be the MAC address of the
24-
* network interface. You can generate this using {@link HomekitServer#generateMac()}.
25-
*
26-
* @return the unique MAC address.
27-
*/
28-
String getMac();
15+
/**
16+
* A pin code used for pairing the device. This pin will be required within iOS in order to
17+
* complete pairing. The numbers cannot be sequential and should not have a repeating pattern.
18+
*
19+
* @return the pin code, in the form ###-##-###
20+
*/
21+
String getPin();
2922

30-
/**
31-
* The Salt that will be used when hashing the pin code to send to the client. You should generate this using
32-
* {@link HomekitServer#generateSalt()}.
33-
*
34-
* @return the Salt.
35-
*/
36-
BigInteger getSalt();
23+
/**
24+
* A unique MAC address to be advertised with the Homekit information. This does not have to be
25+
* the MAC address of the network interface. You can generate this using {@link
26+
* HomekitServer#generateMac()}.
27+
*
28+
* @return the unique MAC address.
29+
*/
30+
String getMac();
3731

38-
/**
39-
* The private key used by the server during pairing and message encryption. You should generate this using
40-
* {@link HomekitServer#generateKey()}
41-
*
42-
* @return the private key.
43-
*/
44-
byte[] getPrivateKey();
45-
46-
/**
47-
* Called during the pairing process, you should store the user and public key in a manner that the public key can later
48-
* be retrieved using {@link #getUserPublicKey(String)}. This must be stored in a persistent store as pairing will
49-
* need to be reset if the information is lost.
50-
*
51-
* @param username the iOS device's username. The value will not be meaningful to anything but iOS.
52-
* @param publicKey the iOS device's public key.
53-
*/
54-
void createUser(String username, byte[] publicKey);
55-
56-
/**
57-
* Called when an iOS device needs to remove an existing pairing. Subsequent calls to {@link #getUserPublicKey(String)} for this
58-
* username return null.
59-
*
60-
* @param username the username to delete from the persistent store.
61-
*/
62-
void removeUser(String username);
32+
/**
33+
* The Salt that will be used when hashing the pin code to send to the client. You should generate
34+
* this using {@link HomekitServer#generateSalt()}.
35+
*
36+
* @return the Salt.
37+
*/
38+
BigInteger getSalt();
6339

64-
/**
65-
* Called when an already paired iOS device is re-connecting. The public key returned by this method will be compared
66-
* with the signature of the pair verification request to validate the device.
67-
*
68-
* @param username the username of the iOS device to retrieve the public key for.
69-
* @return the previously stored public key for this user.
70-
*/
71-
byte[] getUserPublicKey(String username);
72-
73-
/**
74-
* Called to check if a user has been created. The homekit accessory advertises whether the accessory has already been paired.
75-
* At this time, it's unclear whether multiple users can be created, however it is known that advertising as unpaired
76-
* will break in iOS 9. The default value has been provided to maintain API compatibility for implementations targeting iOS 8.
77-
*
78-
* @return whether a user has been created and stored
79-
*/
80-
default boolean hasUser() { return false; };
40+
/**
41+
* The private key used by the server during pairing and message encryption. You should generate
42+
* this using {@link HomekitServer#generateKey()}
43+
*
44+
* @return the private key.
45+
*/
46+
byte[] getPrivateKey();
47+
48+
/**
49+
* Called during the pairing process, you should store the user and public key in a manner that
50+
* the public key can later be retrieved using {@link #getUserPublicKey(String)}. This must be
51+
* stored in a persistent store as pairing will need to be reset if the information is lost.
52+
*
53+
* @param username the iOS device's username. The value will not be meaningful to anything but
54+
* iOS.
55+
* @param publicKey the iOS device's public key.
56+
*/
57+
void createUser(String username, byte[] publicKey);
58+
59+
/**
60+
* Called when an iOS device needs to remove an existing pairing. Subsequent calls to {@link
61+
* #getUserPublicKey(String)} for this username return null.
62+
*
63+
* @param username the username to delete from the persistent store.
64+
*/
65+
void removeUser(String username);
66+
67+
/**
68+
* Called when an already paired iOS device is re-connecting. The public key returned by this
69+
* method will be compared with the signature of the pair verification request to validate the
70+
* device.
71+
*
72+
* @param username the username of the iOS device to retrieve the public key for.
73+
* @return the previously stored public key for this user.
74+
*/
75+
byte[] getUserPublicKey(String username);
76+
77+
/**
78+
* Called to check if a user has been created. The homekit accessory advertises whether the
79+
* accessory has already been paired. At this time, it's unclear whether multiple users can be
80+
* created, however it is known that advertising as unpaired will break in iOS 9. The default
81+
* value has been provided to maintain API compatibility for implementations targeting iOS 8.
82+
*
83+
* @return whether a user has been created and stored
84+
*/
85+
default boolean hasUser() {
86+
return false;
87+
};
8188
}

src/main/java/com/beowulfe/hap/HomekitCharacteristicChangeCallback.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
import com.beowulfe.hap.characteristics.EventableCharacteristic;
44

55
/**
6-
* A callback interface for notifying subscribers that a characteristic value has changed.
7-
*
8-
* {@link EventableCharacteristic}s can be subscribed to, and in doing so, are supplied an instance of this class. Implementors
9-
* should call the {@link #changed()} method on the passed object when a subscribed characteristic changes.
6+
* A callback interface for notifying subscribers that a characteristic value has changed.
7+
*
8+
* <p>{@link EventableCharacteristic}s can be subscribed to, and in doing so, are supplied an
9+
* instance of this class. Implementors should call the {@link #changed()} method on the passed
10+
* object when a subscribed characteristic changes.
1011
*
1112
* @author Andy Lintner
1213
*/
1314
@FunctionalInterface
1415
public interface HomekitCharacteristicChangeCallback {
1516

16-
/**
17-
* Call when the value of the characteristic that was subscribed to when this object was passed changes.
18-
*/
19-
void changed();
17+
/**
18+
* Call when the value of the characteristic that was subscribed to when this object was passed
19+
* changes.
20+
*/
21+
void changed();
2022
}

0 commit comments

Comments
 (0)