From f609a797cb7d0a850df824529f4da2a58f7399b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20K=C3=B6rber?= Date: Wed, 22 Aug 2018 18:14:40 +0200 Subject: [PATCH] Checkstyle fixes --- .../java/org/shredzone/acme4j/Identifier.java | 54 +++++++++---------- .../main/java/org/shredzone/acme4j/Order.java | 2 +- .../org/shredzone/acme4j/IdentifierTest.java | 12 ++--- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/Identifier.java b/acme4j-client/src/main/java/org/shredzone/acme4j/Identifier.java index 16e7d479..d02a0cef 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/Identifier.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/Identifier.java @@ -46,14 +46,14 @@ public class Identifier implements Serializable { /** * Type constant for DNS identifiers. */ - public static final String DNS = "dns"; + public static final String TYPE_DNS = "dns"; /** * Type constant for IP identifiers. * * @see draft-ietf-acme-ip */ - public static final String IP = "ip"; + public static final String TYPE_IP = "ip"; private static final String KEY_TYPE = "type"; private static final String KEY_VALUE = "value"; @@ -61,28 +61,6 @@ public class Identifier implements Serializable { private final String type; private final String value; - /** - * Creates a new DNS identifier for the given domain name. - * - * @param domain - * Domain name. Unicode domains are automatically ASCII encoded. - * @return New {@link Identifier} - */ - public static Identifier dns(String domain) { - return new Identifier(DNS, toAce(domain)); - } - - /** - * Creates a new IP identifier for the given {@link InetAddress}. - * - * @param ip - * {@link InetAddress} - * @return New {@link Identifier} - */ - public static Identifier ip(InetAddress ip) { - return new Identifier(IP, ip.getHostAddress()); - } - /** * Creates a new {@link Identifier}. *

@@ -112,6 +90,28 @@ public class Identifier implements Serializable { this(json.get(KEY_TYPE).asString(), json.get(KEY_VALUE).asString()); } + /** + * Creates a new DNS identifier for the given domain name. + * + * @param domain + * Domain name. Unicode domains are automatically ASCII encoded. + * @return New {@link Identifier} + */ + public static Identifier dns(String domain) { + return new Identifier(TYPE_DNS, toAce(domain)); + } + + /** + * Creates a new IP identifier for the given {@link InetAddress}. + * + * @param ip + * {@link InetAddress} + * @return New {@link Identifier} + */ + public static Identifier ip(InetAddress ip) { + return new Identifier(TYPE_IP, ip.getHostAddress()); + } + /** * Returns the identifier type. */ @@ -134,7 +134,7 @@ public class Identifier implements Serializable { * if this is not a DNS identifier. */ public String getDomain() { - if (!DNS.equals(type)) { + if (!TYPE_DNS.equals(type)) { throw new AcmeProtocolException("expected 'dns' identifier, but found '" + type + "'"); } return value; @@ -148,7 +148,7 @@ public class Identifier implements Serializable { * if this is not a DNS identifier. */ public InetAddress getIP() { - if (!IP.equals(type)) { + if (!TYPE_IP.equals(type)) { throw new AcmeProtocolException("expected 'ip' identifier, but found '" + type + "'"); } try { @@ -183,6 +183,6 @@ public class Identifier implements Serializable { @Override public int hashCode() { return type.hashCode() ^ value.hashCode(); - }; + } } diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/Order.java b/acme4j-client/src/main/java/org/shredzone/acme4j/Order.java index e82d348c..35452e1d 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/Order.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/Order.java @@ -77,7 +77,7 @@ public class Order extends AcmeJsonResource { @Deprecated public List getDomains() { return getIdentifiers().stream() - .filter(i -> Identifier.DNS.equals(i.getType())) + .filter(i -> Identifier.TYPE_DNS.equals(i.getType())) .map(Identifier::getDomain) .collect(toList()); } diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/IdentifierTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/IdentifierTest.java index 3aa90981..3cab9375 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/IdentifierTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/IdentifierTest.java @@ -31,8 +31,8 @@ public class IdentifierTest { @Test public void testConstants() { - assertThat(Identifier.DNS, is("dns")); - assertThat(Identifier.IP, is("ip")); + assertThat(Identifier.TYPE_DNS, is("dns")); + assertThat(Identifier.TYPE_IP, is("ip")); } @Test @@ -62,12 +62,12 @@ public class IdentifierTest { @Test public void testDns() { Identifier id1 = Identifier.dns("example.com"); - assertThat(id1.getType(), is(Identifier.DNS)); + assertThat(id1.getType(), is(Identifier.TYPE_DNS)); assertThat(id1.getValue(), is("example.com")); assertThat(id1.getDomain(), is("example.com")); Identifier id2 = Identifier.dns("ëxämþlë.com"); - assertThat(id2.getType(), is(Identifier.DNS)); + assertThat(id2.getType(), is(Identifier.TYPE_DNS)); assertThat(id2.getValue(), is("xn--xml-qla7ae5k.com")); assertThat(id2.getDomain(), is("xn--xml-qla7ae5k.com")); } @@ -80,12 +80,12 @@ public class IdentifierTest { @Test public void testIp() throws UnknownHostException { Identifier id1 = Identifier.ip(InetAddress.getByName("192.168.1.2")); - assertThat(id1.getType(), is(Identifier.IP)); + assertThat(id1.getType(), is(Identifier.TYPE_IP)); assertThat(id1.getValue(), is("192.168.1.2")); assertThat(id1.getIP().getHostAddress(), is("192.168.1.2")); Identifier id2 = Identifier.ip(InetAddress.getByName("2001:db8:85a3::8a2e:370:7334")); - assertThat(id2.getType(), is(Identifier.IP)); + assertThat(id2.getType(), is(Identifier.TYPE_IP)); assertThat(id2.getValue(), is("2001:db8:85a3:0:0:8a2e:370:7334")); assertThat(id2.getIP().getHostAddress(), is("2001:db8:85a3:0:0:8a2e:370:7334")); }