Skip to content

Commit

Permalink
bugfix: Remove instance of operators
Browse files Browse the repository at this point in the history
  • Loading branch information
sandordargo committed Oct 18, 2017
1 parent b8848cc commit 79f82a3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 14 deletions.
30 changes: 23 additions & 7 deletions src/main/java/com/jcabi/dynamo/Attributes.java
Expand Up @@ -133,6 +133,28 @@ public Map<String, ExpectedAttributeValue> asKeys() {
return map.build();
}

/**
* With this attribute.
* @param name Attribute name
* @param value The value
* @return Attributes
* @
*/
public Attributes with(final String name, final Long value) {
return this.with(name, new AttributeValue().withN(value.toString()));
}

/**
* With this attribute.
* @param name Attribute name
* @param value The value
* @return Attributes
* @
*/
public Attributes with(final String name, final Integer value) {
return this.with(name, new AttributeValue().withN(value.toString()));
}

/**
* With this attribute.
* @param name Attribute name
Expand All @@ -141,13 +163,7 @@ public Map<String, ExpectedAttributeValue> asKeys() {
* @
*/
public Attributes with(final String name, final Object value) {
final AttributeValue attr;
if (value instanceof Long || value instanceof Integer) {
attr = new AttributeValue().withN(value.toString());
} else {
attr = new AttributeValue(value.toString());
}
return this.with(name, attr);
return this.with(name, new AttributeValue(value.toString()));
}

/**
Expand Down
32 changes: 25 additions & 7 deletions src/main/java/com/jcabi/dynamo/Conditions.java
Expand Up @@ -91,19 +91,37 @@ public Conditions(final Map<String, Condition> map) {
this.conds = Conditions.array(map);
}

/**
* Equal to static condition builder (factory method).
* @param value The value to equal to
* @return The condition just created
*/
public static Condition equalTo(final Long value) {
return Conditions.equalTo(
new AttributeValue().withN(value.toString())
);
}

/**
* Equal to static condition builder (factory method).
* @param value The value to equal to
* @return The condition just created
*/
public static Condition equalTo(final Integer value) {
return Conditions.equalTo(
new AttributeValue().withN(value.toString())
);
}

/**
* Equal to static condition builder (factory method).
* @param value The value to equal to
* @return The condition just created
*/
public static Condition equalTo(final Object value) {
final AttributeValue attr;
if (value instanceof Long || value instanceof Integer) {
attr = new AttributeValue().withN(value.toString());
} else {
attr = new AttributeValue().withS(value.toString());
}
return Conditions.equalTo(attr);
return Conditions.equalTo(
new AttributeValue().withS(value.toString())
);
}

/**
Expand Down

0 comments on commit 79f82a3

Please sign in to comment.