Tabnine Logo
RecurlyObject
Code IndexAdd Tabnine to your IDE (free)

How to use
RecurlyObject
in
com.ning.billing.recurly.model

Best Java code snippets using com.ning.billing.recurly.model.RecurlyObject (Showing top 20 results out of 315)

origin: killbilling/recurly-java-library

public void setUnitAmountCZK(final Object unitAmountCZK) {
  this.unitAmountCZK = RecurlyObject.integerOrNull(unitAmountCZK);
}
origin: killbilling/recurly-java-library

@JsonProperty
public void setHref(final Object href) {
  this.href = stringOrNull(href);
}
origin: killbilling/recurly-java-library

@SuppressWarnings("unchecked")
public static <E extends Enum<E>> E enumOrNull(Class<E> enumClass, @Nullable final Object object) {
  return enumOrNull(enumClass, object, false);
}
origin: com.ning.billing/recurly-java-library

  @Test(groups = "fast")
  public void testNull() {
    Assert.assertEquals(null, RecurlyObject.booleanOrNull(null));
    Assert.assertEquals(null, RecurlyObject.dateTimeOrNull(null));
    Assert.assertEquals(null, RecurlyObject.integerOrNull(null));
    Assert.assertEquals(null, RecurlyObject.stringOrNull(null));
    Assert.assertEquals(null, RecurlyObject.bigDecimalOrNull(null));

    for (final String nil : RecurlyObject.NIL_VAL) {
      final HashMap<String, String> nilMap = new HashMap<String, String>();
      nilMap.put(RecurlyObject.NIL_STR, nil);
      Assert.assertEquals(null, RecurlyObject.booleanOrNull(nilMap));
      Assert.assertEquals(null, RecurlyObject.dateTimeOrNull(nilMap));
      Assert.assertEquals(null, RecurlyObject.integerOrNull(nilMap));
      Assert.assertEquals(null, RecurlyObject.stringOrNull(nilMap));
      Assert.assertEquals(null, RecurlyObject.bigDecimalOrNull(nilMap));
    }

    final HashMap<String, String> nonNilMap = new HashMap<String, String>();
    nonNilMap.put("foo", "bar");
    Assert.assertNotNull(RecurlyObject.isNull(nonNilMap));
  }
}
origin: killbilling/recurly-java-library

public static String stringOrNull(@Nullable final Object object) {
  if (isNull(object)) {
    return null;
  }
  return object.toString().trim();
}
origin: killbilling/recurly-java-library

  public static VerificationResult as(final Object object) {
    if (isNull(object)) {
      return null;
    }
    if (object instanceof Map) {
      final Map map = (Map) object;
      return new VerificationResult(stringOrNull(map.get("code")), stringOrNull(map.get("")));
    }
    return new VerificationResult(null, object.toString());
  }
}
origin: killbilling/recurly-java-library

public static <T> T read(final String payload, final Class<T> clazz) {
  try {
    // TODO Should we cache the mapper?
    return RecurlyObject.newXmlMapper().readValue(payload, clazz);
  } catch (IOException e) {
    log.warn("Enable to read notification, de-serialization failed : {}", e.getMessage());
    return null;
  }
}
origin: killbilling/recurly-java-library

<T extends RecurlyObject> T fetch(final T object, final Class<T> clazz) {
  if (object.getHref() == null || recurlyClient == null) {
    return object;
  }
  return recurlyClient.doGETWithFullURL(clazz, object.getHref());
}
origin: killbilling/recurly-java-library

@Override
public boolean equals(Object o) {
  if (this == o) return true;
  if (o == null || getClass() != o.getClass()) return false;
  if (!super.equals(o)) return false;
  TransactionError that = (TransactionError) o;
  if (errorCode != null ? !errorCode.equals(that.errorCode) : that.errorCode != null) return false;
  if (errorCategory != null ? !errorCategory.equals(that.errorCategory) : that.errorCategory != null)
    return false;
  if (merchantMessage != null ? !merchantMessage.equals(that.merchantMessage) : that.merchantMessage != null)
    return false;
  if (customerMessage != null ? !customerMessage.equals(that.customerMessage) : that.customerMessage != null)
    return false;
  return gatewayErrorCode != null ? gatewayErrorCode.equals(that.gatewayErrorCode) : that.gatewayErrorCode == null;
}
origin: killbilling/recurly-java-library

  @Test(groups = "fast")
  public void testNull() {
    Assert.assertEquals(null, RecurlyObject.booleanOrNull(null));
    Assert.assertEquals(null, RecurlyObject.dateTimeOrNull(null));
    Assert.assertEquals(null, RecurlyObject.integerOrNull(null));
    Assert.assertEquals(null, RecurlyObject.stringOrNull(null));
    Assert.assertEquals(null, RecurlyObject.bigDecimalOrNull(null));

    for (final String nil : RecurlyObject.NIL_VAL) {
      final HashMap<String, String> nilMap = new HashMap<String, String>();
      nilMap.put(RecurlyObject.NIL_STR, nil);
      Assert.assertEquals(null, RecurlyObject.booleanOrNull(nilMap));
      Assert.assertEquals(null, RecurlyObject.dateTimeOrNull(nilMap));
      Assert.assertEquals(null, RecurlyObject.integerOrNull(nilMap));
      Assert.assertEquals(null, RecurlyObject.stringOrNull(nilMap));
      Assert.assertEquals(null, RecurlyObject.bigDecimalOrNull(nilMap));
    }

    final HashMap<String, String> nonNilMap = new HashMap<String, String>();
    nonNilMap.put("foo", "bar");
    Assert.assertNotNull(RecurlyObject.isNull(nonNilMap));
  }
}
origin: killbilling/recurly-java-library

@SuppressWarnings("unchecked")
public static <E extends Enum<E>> E enumOrNull(Class<E> enumClass, @Nullable final Object object, final Boolean upCase) {
  if (isNull(object)) {
    return null;
  } else if (enumClass.isAssignableFrom(object.getClass())) {
    return (E) object;
  }
  String value =  object.toString().trim();
  if (upCase) {
    value = value.toUpperCase();
  }
  return (E) Enum.valueOf(enumClass, value);
}
origin: killbilling/recurly-java-library

public RecurlyClient(final String apiKey, final String scheme, final String host, final int port, final String version) {
  this.key = DatatypeConverter.printBase64Binary(apiKey.getBytes());
  this.baseUrl = String.format("%s://%s:%d/%s", scheme, host, port, version);
  this.xmlMapper = RecurlyObject.newXmlMapper();
  this.userAgent = buildUserAgent();
  this.rateLimitRemaining = -1;
  loggerWarning();
}
origin: killbilling/recurly-java-library

public void setUnitAmountJPY(final Object unitAmountJPY) {
  this.unitAmountJPY = RecurlyObject.integerOrNull(unitAmountJPY);
}

origin: killbilling/recurly-java-library

public static Boolean booleanOrNull(@Nullable final Object object) {
  if (isNull(object)) {
    return null;
  }
  // Booleans are represented as objects (e.g. <display_quantity type="boolean">false</display_quantity>), which Jackson
  // will interpret as an Object (Map), not Booleans.
  if (object instanceof Map) {
    final Map map = (Map) object;
    if (map.keySet().size() == 2 && "boolean".equalsIgnoreCase((String) map.get("type"))) {
      return Boolean.valueOf((String) map.get(""));
    }
  }
  return Boolean.valueOf(object.toString());
}
origin: com.ning.billing/recurly-java-library

  @BeforeMethod(alwaysRun = true)
  public void setUp() throws Exception {
    xmlMapper = RecurlyObject.newXmlMapper();
  }
}
origin: killbilling/recurly-java-library

public void setUnitAmountNZD(final Object unitAmountNZD) {
  this.unitAmountNZD = RecurlyObject.integerOrNull(unitAmountNZD);
}
origin: killbilling/recurly-java-library

public static BigDecimal bigDecimalOrNull(@Nullable final Object object) {
  if (isNull(object)) {
    return null;
  }
  // BigDecimals are represented as objects (e.g. <tax_rate type="float">0.0875</tax_rate>), which Jackson
  // will interpret as an Object (Map), not Longs.
  if (object instanceof Map) {
    final Map map = (Map) object;
    if (map.keySet().size() == 2 && "float".equalsIgnoreCase((String) map.get("type"))) {
      return new BigDecimal((String) map.get(""));
    }
  }
  return new BigDecimal(object.toString());
}
origin: killbilling/recurly-java-library

  @BeforeMethod(alwaysRun = true)
  public void setUp() throws Exception {
    xmlMapper = RecurlyObject.newXmlMapper();
  }
}
origin: killbilling/recurly-java-library

public void setUnitAmountUSD(final Object unitAmountUSD) {
  this.unitAmountUSD = RecurlyObject.integerOrNull(unitAmountUSD);
}
origin: killbilling/recurly-java-library

public static DateTime dateTimeOrNull(@Nullable final Object object) {
  if (isNull(object)) {
    return null;
  }
  // DateTimes are represented as objects (e.g. <created_at type="dateTime">2011-04-19T07:00:00Z</created_at>), which Jackson
  // will interpret as an Object (Map), not DateTimes.
  if (object instanceof Map) {
    final Map map = (Map) object;
    if (map.keySet().size() == 2 && "dateTime".equalsIgnoreCase((String) map.get("type"))) {
      return new DateTime(map.get(""));
    }
  }
  return new DateTime(object.toString());
}
com.ning.billing.recurly.modelRecurlyObject

Most used methods

  • integerOrNull
  • isNull
  • newXmlMapper
  • stringOrNull
  • bigDecimalOrNull
  • booleanOrNull
  • dateTimeOrNull
  • enumOrNull
  • equals
  • getHref
  • setHref
  • setRecurlyClient
  • setHref,
  • setRecurlyClient

Popular in Java

  • Start an intent from android
  • notifyDataSetChanged (ArrayAdapter)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • putExtra (Intent)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now