mirror of https://github.com/apache/jclouds.git
dynect: replace usage of UnsignedInteger with int and fixed serialized form of rdata classes
This commit is contained in:
parent
12fd9bf581
commit
aeee6ceb31
|
@ -26,12 +26,8 @@ import javax.inject.Singleton;
|
|||
import org.jclouds.dynect.v3.domain.SessionCredentials;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.primitives.UnsignedInteger;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.inject.AbstractModule;
|
||||
|
@ -51,7 +47,6 @@ public class DynECTParserModule extends AbstractModule {
|
|||
public Map<Type, Object> provideCustomAdapterBindings() {
|
||||
return new ImmutableMap.Builder<Type, Object>()
|
||||
.put(SessionCredentials.class, new SessionCredentialsTypeAdapter())
|
||||
.put(UnsignedInteger.class, new UnsignedIntegerAdapter())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -64,11 +59,4 @@ public class DynECTParserModule extends AbstractModule {
|
|||
return metadataObject;
|
||||
}
|
||||
}
|
||||
|
||||
private static class UnsignedIntegerAdapter implements JsonDeserializer<UnsignedInteger> {
|
||||
public UnsignedInteger deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
return UnsignedInteger.fromIntBits(jsonElement.getAsBigInteger().intValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,12 @@ package org.jclouds.dynect.v3.domain;
|
|||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Objects.toStringHelper;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.primitives.UnsignedInteger;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
|
@ -34,13 +34,14 @@ public class CreateRecord<D extends Map<String, Object>> {
|
|||
|
||||
private final String fqdn;
|
||||
private final String type;
|
||||
private final UnsignedInteger ttl;
|
||||
private final int ttl;
|
||||
private final D rdata;
|
||||
|
||||
private CreateRecord(String fqdn, String type, UnsignedInteger ttl, D rdata) {
|
||||
private CreateRecord(String fqdn, String type, int ttl, D rdata) {
|
||||
this.fqdn = checkNotNull(fqdn, "fqdn");
|
||||
this.type = checkNotNull(type, "type of %s", fqdn);
|
||||
this.ttl = checkNotNull(ttl, "ttl of %s", fqdn);
|
||||
checkArgument(ttl >= 0, "ttl of %s must be unsigned", fqdn);
|
||||
this.ttl = ttl;
|
||||
this.rdata = checkNotNull(rdata, "rdata of %s", fqdn);
|
||||
}
|
||||
|
||||
|
@ -63,7 +64,7 @@ public class CreateRecord<D extends Map<String, Object>> {
|
|||
*
|
||||
* @see Record#getTTL()
|
||||
*/
|
||||
public UnsignedInteger getTTL() {
|
||||
public int getTTL() {
|
||||
return ttl;
|
||||
}
|
||||
|
||||
|
@ -106,7 +107,8 @@ public class CreateRecord<D extends Map<String, Object>> {
|
|||
public static class Builder<D extends Map<String, Object>> {
|
||||
protected String fqdn;
|
||||
protected String type;
|
||||
protected UnsignedInteger ttl = UnsignedInteger.ZERO;
|
||||
// default of zone is implied when ttl is set to zero
|
||||
protected int ttl = 0;
|
||||
protected D rdata;
|
||||
|
||||
/**
|
||||
|
@ -128,18 +130,11 @@ public class CreateRecord<D extends Map<String, Object>> {
|
|||
/**
|
||||
* @see CreateRecord#getTTL()
|
||||
*/
|
||||
public Builder<D> ttl(UnsignedInteger ttl) {
|
||||
public Builder<D> ttl(int ttl) {
|
||||
this.ttl = ttl;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CreateRecord#getTTL()
|
||||
*/
|
||||
public Builder<D> ttl(int ttl) {
|
||||
return ttl(UnsignedInteger.fromIntBits(ttl));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see CreateRecord#getRData()
|
||||
*/
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.dynect.v3.domain;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
@ -26,28 +27,28 @@ import java.util.Map;
|
|||
import javax.inject.Named;
|
||||
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.primitives.UnsignedInteger;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class Record<D extends Map<String, Object>> extends RecordId {
|
||||
|
||||
private final UnsignedInteger ttl;
|
||||
private final int ttl;
|
||||
@Named("rdata")
|
||||
private final D rdata;
|
||||
|
||||
@ConstructorProperties({ "zone", "fqdn", "record_type", "record_id", "ttl", "rdata" })
|
||||
protected Record(String zone, String fqdn, String type, long id, UnsignedInteger ttl, D rdata) {
|
||||
protected Record(String zone, String fqdn, String type, long id, int ttl, D rdata) {
|
||||
super(zone, fqdn, type, id);
|
||||
this.ttl = checkNotNull(ttl, "ttl of %s", id);
|
||||
checkArgument(ttl >= 0, "ttl of %s must be unsigned", fqdn);
|
||||
this.ttl = ttl;
|
||||
this.rdata = checkNotNull(rdata, "rdata of %s", id);
|
||||
}
|
||||
|
||||
/**
|
||||
* The current ttl of the record or zero if default for the zone
|
||||
*/
|
||||
public UnsignedInteger getTTL() {
|
||||
public int getTTL() {
|
||||
return ttl;
|
||||
}
|
||||
|
||||
|
@ -74,24 +75,17 @@ public class Record<D extends Map<String, Object>> extends RecordId {
|
|||
|
||||
public abstract static class Builder<D extends Map<String, Object>, B extends Builder<D, B>> extends RecordId.Builder<B> {
|
||||
|
||||
protected UnsignedInteger ttl;
|
||||
protected int ttl = -1;
|
||||
protected D rdata;
|
||||
|
||||
/**
|
||||
* @see Record#getTTL()
|
||||
*/
|
||||
public B ttl(UnsignedInteger ttl) {
|
||||
public B ttl(int ttl) {
|
||||
this.ttl = ttl;
|
||||
return self();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Record#getTTL()
|
||||
*/
|
||||
public B ttl(int ttl) {
|
||||
return ttl(UnsignedInteger.fromIntBits(ttl));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Record#getRData()
|
||||
*/
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.jclouds.dynect.v3.domain.Zone.SerialStyle;
|
|||
import org.jclouds.dynect.v3.domain.rdata.SOAData;
|
||||
|
||||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.primitives.UnsignedInteger;
|
||||
|
||||
/**
|
||||
* Start of Authority per RFC 1035
|
||||
|
@ -41,7 +40,7 @@ public final class SOARecord extends Record<SOAData> {
|
|||
private final SerialStyle serialStyle;
|
||||
|
||||
@ConstructorProperties({ "zone", "fqdn", "record_type", "record_id", "ttl", "rdata", "serial_style" })
|
||||
private SOARecord(String zone, String fqdn, String type, long id, UnsignedInteger ttl, SOAData rdata, SerialStyle serialStyle) {
|
||||
private SOARecord(String zone, String fqdn, String type, long id, int ttl, SOAData rdata, SerialStyle serialStyle) {
|
||||
super(zone, fqdn, type, id, ttl, rdata);
|
||||
this.serialStyle = checkNotNull(serialStyle, "serialStyle of %s", id);
|
||||
}
|
||||
|
|
|
@ -40,22 +40,25 @@ import com.google.common.collect.ImmutableMap;
|
|||
* @see <aaaa href="http://www.ietf.org/rfc/rfc3596.txt">RFC 3596</aaaa>
|
||||
*/
|
||||
public class AAAAData extends ForwardingMap<String, Object> {
|
||||
private final ImmutableMap<String, Object> delegate;
|
||||
private final String address;
|
||||
|
||||
@ConstructorProperties("address")
|
||||
private AAAAData(String address) {
|
||||
this.delegate = ImmutableMap.<String, Object> of("address", checkNotNull(address, "address"));
|
||||
}
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
this.address = checkNotNull(address, "address");
|
||||
this.delegate = ImmutableMap.<String, Object> of("address", address);
|
||||
}
|
||||
|
||||
/**
|
||||
* a 128 bit IPv6 address
|
||||
*/
|
||||
public String getAddress() {
|
||||
return get("address").toString();
|
||||
return address;
|
||||
}
|
||||
|
||||
private final transient ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public static AAAAData aaaa(String address) {
|
||||
|
|
|
@ -40,22 +40,26 @@ import com.google.common.collect.ImmutableMap;
|
|||
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
|
||||
*/
|
||||
public class AData extends ForwardingMap<String, Object> {
|
||||
private final ImmutableMap<String, Object> delegate;
|
||||
|
||||
private final String address;
|
||||
|
||||
@ConstructorProperties("address")
|
||||
private AData(String address) {
|
||||
this.address = checkNotNull(address, "address");
|
||||
this.delegate = ImmutableMap.<String, Object> of("address", checkNotNull(address, "address"));
|
||||
}
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* a 32-bit internet address
|
||||
*/
|
||||
public String getAddress() {
|
||||
return get("address").toString();
|
||||
return address;
|
||||
}
|
||||
|
||||
private final transient ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public static AData a(String address) {
|
||||
|
|
|
@ -40,15 +40,13 @@ import com.google.common.collect.ImmutableMap;
|
|||
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
|
||||
*/
|
||||
public class CNAMEData extends ForwardingMap<String, Object> {
|
||||
private final ImmutableMap<String, Object> delegate;
|
||||
|
||||
private final String cname;
|
||||
|
||||
@ConstructorProperties("cname")
|
||||
private CNAMEData(String cname) {
|
||||
this.delegate = ImmutableMap.<String, Object> of("cname", checkNotNull(cname, "cname"));
|
||||
}
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
this.cname = checkNotNull(cname, "cname");
|
||||
this.delegate = ImmutableMap.<String, Object> of("cname", cname);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,7 +54,13 @@ public class CNAMEData extends ForwardingMap<String, Object> {
|
|||
* The owner name is an alias.
|
||||
*/
|
||||
public String getCname() {
|
||||
return get("cname").toString();
|
||||
return cname;
|
||||
}
|
||||
|
||||
private final transient ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public static CNAMEData cname(String cname) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.dynect.v3.domain.rdata;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
@ -25,7 +26,6 @@ import java.util.Map;
|
|||
|
||||
import com.google.common.collect.ForwardingMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.primitives.UnsignedInteger;
|
||||
|
||||
/**
|
||||
* Corresponds to the binary representation of the {@code MX} (Mail Exchange)
|
||||
|
@ -43,24 +43,24 @@ import com.google.common.primitives.UnsignedInteger;
|
|||
*/
|
||||
public class MXData extends ForwardingMap<String, Object> {
|
||||
|
||||
private final int preference;
|
||||
private final String exchange;
|
||||
|
||||
@ConstructorProperties({ "preference", "exchange" })
|
||||
private MXData(UnsignedInteger preference, String exchange) {
|
||||
this.delegate = ImmutableMap.<String, Object> builder().put("preference", checkNotNull(preference, "preference"))
|
||||
.put("exchange", checkNotNull(exchange, "exchange")).build();
|
||||
}
|
||||
|
||||
private final ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
private MXData(int preference, String exchange) {
|
||||
checkArgument(preference >= 0, "preference of %s must be unsigned", exchange);
|
||||
this.preference = preference;
|
||||
this.exchange = checkNotNull(exchange, "exchange");
|
||||
this.delegate = ImmutableMap.<String, Object> builder().put("preference", preference).put("exchange", exchange)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* specifies the preference given to this RR among others at the same owner.
|
||||
* Lower values are preferred.
|
||||
*/
|
||||
public UnsignedInteger getPreference() {
|
||||
return UnsignedInteger.class.cast(get("preference"));
|
||||
public int getPreference() {
|
||||
return preference;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,7 +68,13 @@ public class MXData extends ForwardingMap<String, Object> {
|
|||
* the owner name.
|
||||
*/
|
||||
public String getExchange() {
|
||||
return String.class.cast(get("exchange"));
|
||||
return exchange;
|
||||
}
|
||||
|
||||
private final transient ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public static MXData mx(int preference, String exchange) {
|
||||
|
@ -84,20 +90,13 @@ public class MXData extends ForwardingMap<String, Object> {
|
|||
}
|
||||
|
||||
public final static class Builder {
|
||||
private UnsignedInteger preference;
|
||||
private int preference = -1;
|
||||
private String exchange;
|
||||
|
||||
/**
|
||||
* @see MXData#getPreference()
|
||||
*/
|
||||
public MXData.Builder preference(int preference) {
|
||||
return preference(UnsignedInteger.fromIntBits(preference));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see MXData#getPreference()
|
||||
*/
|
||||
public MXData.Builder preference(UnsignedInteger preference) {
|
||||
this.preference = preference;
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -40,15 +40,13 @@ import com.google.common.collect.ImmutableMap;
|
|||
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
|
||||
*/
|
||||
public class NSData extends ForwardingMap<String, Object> {
|
||||
private final ImmutableMap<String, Object> delegate;
|
||||
|
||||
private final String nsdname;
|
||||
|
||||
@ConstructorProperties("nsdname")
|
||||
private NSData(String nsdname) {
|
||||
this.delegate = ImmutableMap.<String, Object> of("nsdname", checkNotNull(nsdname, "nsdname"));
|
||||
}
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
this.nsdname = checkNotNull(nsdname, "nsdname");
|
||||
this.delegate = ImmutableMap.<String, Object> of("nsdname", nsdname);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,7 +54,13 @@ public class NSData extends ForwardingMap<String, Object> {
|
|||
* specified class and domain.
|
||||
*/
|
||||
public String getNsdname() {
|
||||
return get("nsdname").toString();
|
||||
return nsdname;
|
||||
}
|
||||
|
||||
private final transient ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public static NSData ns(String nsdname) {
|
||||
|
|
|
@ -40,22 +40,26 @@ import com.google.common.collect.ImmutableMap;
|
|||
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
|
||||
*/
|
||||
public class PTRData extends ForwardingMap<String, Object> {
|
||||
private final ImmutableMap<String, Object> delegate;
|
||||
|
||||
private final String ptrdname;
|
||||
|
||||
@ConstructorProperties("ptrdname")
|
||||
private PTRData(String ptrdname) {
|
||||
this.delegate = ImmutableMap.<String, Object> of("ptrdname", checkNotNull(ptrdname, "ptrdname"));
|
||||
}
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
this.ptrdname = checkNotNull(ptrdname, "ptrdname");
|
||||
this.delegate = ImmutableMap.<String, Object> of("ptrdname", ptrdname);
|
||||
}
|
||||
|
||||
/**
|
||||
* domain-name which points to some location in the domain name space.
|
||||
*/
|
||||
public String getPtrdname() {
|
||||
return get("ptrdname").toString();
|
||||
return ptrdname;
|
||||
}
|
||||
|
||||
private final transient ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public static PTRData ptr(String ptrdname) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.dynect.v3.domain.rdata;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
@ -25,7 +26,6 @@ import java.util.Map;
|
|||
|
||||
import com.google.common.collect.ForwardingMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.primitives.UnsignedInteger;
|
||||
|
||||
/**
|
||||
* Corresponds to the binary representation of the {@code SOA} (Start of Authority) RData
|
||||
|
@ -46,10 +46,29 @@ import com.google.common.primitives.UnsignedInteger;
|
|||
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
|
||||
*/
|
||||
public class SOAData extends ForwardingMap<String, Object> {
|
||||
private final String mname;
|
||||
private final String rname;
|
||||
private final int serial;
|
||||
private final int refresh;
|
||||
private final int retry;
|
||||
private final int expire;
|
||||
private final int minimum;
|
||||
|
||||
@ConstructorProperties({ "mname", "rname", "serial", "refresh", "retry", "expire", "minimum" })
|
||||
private SOAData(String mname, String rname, UnsignedInteger serial, UnsignedInteger refresh, UnsignedInteger retry,
|
||||
UnsignedInteger expire, UnsignedInteger minimum) {
|
||||
private SOAData(String mname, String rname, int serial, int refresh, int retry,
|
||||
int expire, int minimum) {
|
||||
this.mname = checkNotNull(mname, "mname");
|
||||
this.rname = checkNotNull(rname, "rname of %s", mname);
|
||||
checkArgument(serial >= 0, "serial of %s must be unsigned", mname);
|
||||
this.serial = serial;
|
||||
checkArgument(refresh >= 0, "refresh of %s must be unsigned", mname);
|
||||
this.refresh = refresh;
|
||||
checkArgument(retry >= 0, "retry of %s must be unsigned", mname);
|
||||
this.retry = retry;
|
||||
checkArgument(expire >= 0, "expire of %s must be unsigned", mname);
|
||||
this.expire = expire;
|
||||
checkArgument(minimum >= 0, "minimum of %s must be unsigned", mname);
|
||||
this.minimum = minimum;
|
||||
this.delegate = ImmutableMap.<String, Object> builder()
|
||||
.put("mname", checkNotNull(mname, "mname"))
|
||||
.put("rname", checkNotNull(rname, "rname of %s", mname))
|
||||
|
@ -60,18 +79,12 @@ public class SOAData extends ForwardingMap<String, Object> {
|
|||
.put("minimum", checkNotNull(minimum, "minimum of %s", mname)).build();
|
||||
}
|
||||
|
||||
private final ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* domain-name of the name server that was the original or primary source of
|
||||
* data for this zone
|
||||
*/
|
||||
public String getMname() {
|
||||
return String.class.cast(get("mname"));
|
||||
return mname;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,43 +92,49 @@ public class SOAData extends ForwardingMap<String, Object> {
|
|||
* zone.
|
||||
*/
|
||||
public String getRname() {
|
||||
return String.class.cast(get("rname"));
|
||||
return rname;
|
||||
}
|
||||
|
||||
/**
|
||||
* version number of the original copy of the zone.
|
||||
*/
|
||||
public UnsignedInteger getSerial() {
|
||||
return UnsignedInteger.class.cast(get("serial"));
|
||||
public int getSerial() {
|
||||
return serial;
|
||||
}
|
||||
|
||||
/**
|
||||
* time interval before the zone should be refreshed
|
||||
*/
|
||||
public UnsignedInteger getRefresh() {
|
||||
return UnsignedInteger.class.cast(get("refresh"));
|
||||
public int getRefresh() {
|
||||
return refresh;
|
||||
}
|
||||
|
||||
/**
|
||||
* time interval that should elapse before a failed refresh should be retried
|
||||
*/
|
||||
public UnsignedInteger getRetry() {
|
||||
return UnsignedInteger.class.cast(get("retry"));
|
||||
public int getRetry() {
|
||||
return retry;
|
||||
}
|
||||
|
||||
/**
|
||||
* time value that specifies the upper limit on the time interval that can
|
||||
* elapse before the zone is no longer authoritative.
|
||||
*/
|
||||
public UnsignedInteger getExpire() {
|
||||
return UnsignedInteger.class.cast(get("expire"));
|
||||
public int getExpire() {
|
||||
return expire;
|
||||
}
|
||||
|
||||
/**
|
||||
* minimum TTL field that should be exported with any RR from this zone.
|
||||
*/
|
||||
public UnsignedInteger getMinimum() {
|
||||
return UnsignedInteger.class.cast(get("minimum"));
|
||||
public int getMinimum() {
|
||||
return minimum;
|
||||
}
|
||||
|
||||
private final transient ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public static SOAData.Builder builder() {
|
||||
|
@ -129,11 +148,11 @@ public class SOAData extends ForwardingMap<String, Object> {
|
|||
public final static class Builder {
|
||||
private String mname;
|
||||
private String rname;
|
||||
private UnsignedInteger serial;
|
||||
private UnsignedInteger refresh;
|
||||
private UnsignedInteger retry;
|
||||
private UnsignedInteger expire;
|
||||
private UnsignedInteger minimum;
|
||||
private int serial = -1;
|
||||
private int refresh = -1;
|
||||
private int retry = -1;
|
||||
private int expire = -1;
|
||||
private int minimum = -1;
|
||||
|
||||
/**
|
||||
* @see SOAData#getMname()
|
||||
|
@ -151,26 +170,11 @@ public class SOAData extends ForwardingMap<String, Object> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SOAData#getSerial()
|
||||
*/
|
||||
public SOAData.Builder serial(UnsignedInteger serial) {
|
||||
this.serial = serial;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SOAData#getSerial()
|
||||
*/
|
||||
public SOAData.Builder serial(int serial) {
|
||||
return serial(UnsignedInteger.fromIntBits(serial));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SOAData#getRefresh()
|
||||
*/
|
||||
public SOAData.Builder refresh(UnsignedInteger refresh) {
|
||||
this.refresh = refresh;
|
||||
this.serial = serial;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -178,14 +182,7 @@ public class SOAData extends ForwardingMap<String, Object> {
|
|||
* @see SOAData#getRefresh()
|
||||
*/
|
||||
public SOAData.Builder refresh(int refresh) {
|
||||
return refresh(UnsignedInteger.fromIntBits(refresh));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SOAData#getRetry()
|
||||
*/
|
||||
public SOAData.Builder retry(UnsignedInteger retry) {
|
||||
this.retry = retry;
|
||||
this.refresh = refresh;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -193,14 +190,7 @@ public class SOAData extends ForwardingMap<String, Object> {
|
|||
* @see SOAData#getRetry()
|
||||
*/
|
||||
public SOAData.Builder retry(int retry) {
|
||||
return retry(UnsignedInteger.fromIntBits(retry));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SOAData#getExpire()
|
||||
*/
|
||||
public SOAData.Builder expire(UnsignedInteger expire) {
|
||||
this.expire = expire;
|
||||
this.retry = retry;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -208,14 +198,7 @@ public class SOAData extends ForwardingMap<String, Object> {
|
|||
* @see SOAData#getExpire()
|
||||
*/
|
||||
public SOAData.Builder expire(int expire) {
|
||||
return expire(UnsignedInteger.fromIntBits(expire));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SOAData#getMinimum()
|
||||
*/
|
||||
public SOAData.Builder minimum(UnsignedInteger minimum) {
|
||||
this.minimum = minimum;
|
||||
this.expire = expire;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -223,7 +206,8 @@ public class SOAData extends ForwardingMap<String, Object> {
|
|||
* @see SOAData#getMinimum()
|
||||
*/
|
||||
public SOAData.Builder minimum(int minimum) {
|
||||
return minimum(UnsignedInteger.fromIntBits(minimum));
|
||||
this.minimum = minimum;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SOAData build() {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.dynect.v3.domain.rdata;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
@ -25,7 +26,6 @@ import java.util.Map;
|
|||
|
||||
import com.google.common.collect.ForwardingMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.primitives.UnsignedInteger;
|
||||
|
||||
/**
|
||||
* Corresponds to the binary representation of the {@code SRV} (Service) RData
|
||||
|
@ -43,31 +43,36 @@ import com.google.common.primitives.UnsignedInteger;
|
|||
* @see <a href="http://www.ietf.org/rfc/rfc2782.txt">RFC 2782</a>
|
||||
*/
|
||||
public class SRVData extends ForwardingMap<String, Object> {
|
||||
private final int priority;
|
||||
private final int weight;
|
||||
private final int port;
|
||||
private final String target;
|
||||
|
||||
@ConstructorProperties({ "priority", "weight", "port", "target" })
|
||||
private SRVData(UnsignedInteger priority, UnsignedInteger weight, UnsignedInteger port, String target) {
|
||||
private SRVData(int priority, int weight, int port, String target) {
|
||||
checkArgument(checkNotNull(priority, "priority of %s", target).intValue() <= 0xFFFF, "priority must be 0-65535");
|
||||
this.priority = priority;
|
||||
checkArgument(checkNotNull(weight, "weight of %s", target).intValue() <= 0xFFFF, "weight must be 0-65535");
|
||||
this.weight = weight;
|
||||
checkArgument(checkNotNull(port, "port of %s", target).intValue() <= 0xFFFF, "port must be 0-65535");
|
||||
this.port = port;
|
||||
this.target = checkNotNull(target, "target");
|
||||
this.delegate = ImmutableMap.<String, Object> builder()
|
||||
.put("priority", checkNotNull(priority, "priority of %s", target))
|
||||
.put("weight", checkNotNull(weight, "weight of %s", target))
|
||||
.put("port", checkNotNull(port, "port of %s", target))
|
||||
.put("target", checkNotNull(target, "target"))
|
||||
.put("priority", priority)
|
||||
.put("weight", weight)
|
||||
.put("port", weight)
|
||||
.put("target", weight)
|
||||
.build();
|
||||
}
|
||||
|
||||
private final ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* The priority of this target host. A client MUST attempt to contact the
|
||||
* target host with the lowest-numbered priority it can reach; target hosts
|
||||
* with the same priority SHOULD be tried in an order defined by the weight
|
||||
* field.
|
||||
*/
|
||||
public UnsignedInteger getPriority() {
|
||||
return UnsignedInteger.class.cast(get("priority"));
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,15 +80,15 @@ public class SRVData extends ForwardingMap<String, Object> {
|
|||
* priority. Larger weights SHOULD be given a proportionately higher
|
||||
* probability of being selected.
|
||||
*/
|
||||
public UnsignedInteger getWeight() {
|
||||
return UnsignedInteger.class.cast(get("weight"));
|
||||
public int getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* The port on this target host of this service.
|
||||
*/
|
||||
public UnsignedInteger getPort() {
|
||||
return UnsignedInteger.class.cast(get("port"));
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,7 +96,13 @@ public class SRVData extends ForwardingMap<String, Object> {
|
|||
* records for this name, the name MUST NOT be an alias.
|
||||
*/
|
||||
public String getTarget() {
|
||||
return String.class.cast(get("target"));
|
||||
return target;
|
||||
}
|
||||
|
||||
private final transient ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public static SRVData.Builder builder() {
|
||||
|
@ -103,31 +114,16 @@ public class SRVData extends ForwardingMap<String, Object> {
|
|||
}
|
||||
|
||||
public final static class Builder {
|
||||
private UnsignedInteger priority;
|
||||
private UnsignedInteger weight;
|
||||
private UnsignedInteger port;
|
||||
private int priority = -1;
|
||||
private int weight = -1;
|
||||
private int port = -1;
|
||||
private String target;
|
||||
|
||||
/**
|
||||
* @see SRVData#getPriority()
|
||||
*/
|
||||
public SRVData.Builder priority(UnsignedInteger priority) {
|
||||
this.priority = priority;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SRVData#getPriority()
|
||||
*/
|
||||
public SRVData.Builder priority(int priority) {
|
||||
return priority(UnsignedInteger.fromIntBits(priority));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SRVData#getWeight()
|
||||
*/
|
||||
public SRVData.Builder weight(UnsignedInteger weight) {
|
||||
this.weight = weight;
|
||||
this.priority = priority;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -135,14 +131,7 @@ public class SRVData extends ForwardingMap<String, Object> {
|
|||
* @see SRVData#getWeight()
|
||||
*/
|
||||
public SRVData.Builder weight(int weight) {
|
||||
return weight(UnsignedInteger.fromIntBits(weight));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SRVData#getPort()
|
||||
*/
|
||||
public SRVData.Builder port(UnsignedInteger port) {
|
||||
this.port = port;
|
||||
this.weight = weight;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -150,7 +139,8 @@ public class SRVData extends ForwardingMap<String, Object> {
|
|||
* @see SRVData#getPort()
|
||||
*/
|
||||
public SRVData.Builder port(int port) {
|
||||
return port(UnsignedInteger.fromIntBits(port));
|
||||
this.port = port;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,22 +40,26 @@ import com.google.common.collect.ImmutableMap;
|
|||
* @see <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>
|
||||
*/
|
||||
public class TXTData extends ForwardingMap<String, Object> {
|
||||
private final ImmutableMap<String, Object> delegate;
|
||||
|
||||
private final String txtdata;
|
||||
|
||||
@ConstructorProperties("txtdata")
|
||||
private TXTData(String txtdata) {
|
||||
this.delegate = ImmutableMap.<String, Object> of("txtdata", checkNotNull(txtdata, "txtdata"));
|
||||
}
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
this.txtdata = checkNotNull(txtdata, "txtdata");
|
||||
this.delegate = ImmutableMap.<String, Object> of("txtdata", txtdata);
|
||||
}
|
||||
|
||||
/**
|
||||
* One or more character-strings.
|
||||
*/
|
||||
public String getTxtdata() {
|
||||
return get("txtdata").toString();
|
||||
return txtdata;
|
||||
}
|
||||
|
||||
private final transient ImmutableMap<String, Object> delegate;
|
||||
|
||||
protected Map<String, Object> delegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public static TXTData txt(String txtdata) {
|
||||
|
|
|
@ -128,7 +128,7 @@ public interface RecordAsyncApi {
|
|||
.put("fqdn", in.getFQDN()).build());
|
||||
return (R) request.toBuilder()
|
||||
.endpoint(path)
|
||||
.payload(json.toJson(ImmutableMap.of("rdata", ImmutableMap.copyOf(in.getRData()), "ttl", in.getTTL().intValue()))).build();
|
||||
.payload(json.toJson(ImmutableMap.of("rdata", in.getRData(), "ttl", in.getTTL()))).build();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue