Skip to content

Commit

Permalink
#113 diamonds
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 13, 2022
1 parent b028d38 commit dbcfd8c
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 34 deletions.
8 changes: 4 additions & 4 deletions src/main/java/com/jcabi/dynamo/AttributeUpdates.java
Expand Up @@ -74,15 +74,15 @@ public final class AttributeUpdates
* Private ctor.
*/
public AttributeUpdates() {
this(new ArrayMap<String, AttributeValueUpdate>());
this(new ArrayMap<>());
}

/**
* Private ctor.
* @param map Map of them
*/
public AttributeUpdates(final Map<String, AttributeValueUpdate> map) {
this.attrs = new ArrayMap<String, AttributeValueUpdate>(map);
this.attrs = new ArrayMap<>(map);
}

/**
Expand Down Expand Up @@ -137,7 +137,7 @@ public AttributeUpdates with(final String name, final Object value) {
*/
public AttributeUpdates with(final Map<String, AttributeValueUpdate> map) {
final ConcurrentMap<String, AttributeValueUpdate> attribs =
new ConcurrentHashMap<String, AttributeValueUpdate>(map.size());
new ConcurrentHashMap<>(map.size());
for (final Map.Entry<String, AttributeValueUpdate> entry
: map.entrySet()) {
attribs.put(
Expand All @@ -151,7 +151,7 @@ public AttributeUpdates with(final Map<String, AttributeValueUpdate> map) {
@Override
public String toString() {
final Collection<String> terms =
new ArrayList<String>(this.attrs.size());
new ArrayList<>(this.attrs.size());
for (final Map.Entry<String, AttributeValueUpdate> attr
: this.attrs.entrySet()) {
terms.add(
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/jcabi/dynamo/Attributes.java
Expand Up @@ -81,15 +81,15 @@ public final class Attributes implements Map<String, AttributeValue> {
* Private ctor.
*/
public Attributes() {
this(new ArrayMap<String, AttributeValue>());
this(new ArrayMap<>());
}

/**
* Private ctor.
* @param map Map of them
*/
public Attributes(final Map<String, AttributeValue> map) {
this.attrs = new ArrayMap<String, AttributeValue>(map);
this.attrs = new ArrayMap<>(map);
}

/**
Expand All @@ -109,7 +109,7 @@ public Attributes with(final String name, final AttributeValue value) {
*/
public Attributes with(final Map<String, AttributeValue> map) {
final ConcurrentMap<String, AttributeValue> attribs =
new ConcurrentHashMap<String, AttributeValue>(map.size());
new ConcurrentHashMap<>(map.size());
for (final Map.Entry<String, AttributeValue> entry : map.entrySet()) {
attribs.put(entry.getKey(), entry.getValue());
}
Expand All @@ -122,7 +122,7 @@ public Attributes with(final Map<String, AttributeValue> map) {
*/
public Map<String, ExpectedAttributeValue> asKeys() {
final ImmutableMap.Builder<String, ExpectedAttributeValue> map =
new ImmutableMap.Builder<String, ExpectedAttributeValue>();
new ImmutableMap.Builder<>();
for (final Map.Entry<String, AttributeValue> attr
: this.attrs.entrySet()) {
map.put(
Expand Down Expand Up @@ -173,8 +173,8 @@ public Attributes with(final String name, final Object value) {
*/
public Attributes only(final Iterable<String> keys) {
final ImmutableMap.Builder<String, AttributeValue> map =
new ImmutableMap.Builder<String, AttributeValue>();
final Collection<String> hash = new HashSet<String>(0);
new ImmutableMap.Builder<>();
final Collection<String> hash = new HashSet<>(0);
for (final String key : keys) {
hash.add(key);
}
Expand All @@ -192,7 +192,7 @@ public Attributes only(final Iterable<String> keys) {
@Override
public String toString() {
final Collection<String> terms =
new ArrayList<String>(this.attrs.size());
new ArrayList<>(this.attrs.size());
for (final Map.Entry<String, AttributeValue> attr
: this.attrs.entrySet()) {
terms.add(
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/jcabi/dynamo/AwsIterator.java
Expand Up @@ -127,7 +127,7 @@ final class AwsIterator implements Iterator<Item> {
this.conditions = conds;
this.keys = primary;
this.valve = vlv;
this.dosage = new AtomicReference<Dosage>();
this.dosage = new AtomicReference<>();
this.position = -1;
}

Expand Down Expand Up @@ -175,7 +175,7 @@ public Item next() {
this.frame,
this.name,
new Attributes(this.dosage.get().items().get(this.position)),
new Array<String>(this.keys)
new Array<>(this.keys)
);
}
}
Expand All @@ -188,7 +188,7 @@ public void remove() {
try {
final Dosage prev = this.dosage.get();
final List<Map<String, AttributeValue>> items =
new ArrayList<Map<String, AttributeValue>>(prev.items());
new ArrayList<>(prev.items());
final Map<String, AttributeValue> item =
items.remove(this.position);
final long start = System.currentTimeMillis();
Expand Down Expand Up @@ -240,7 +240,7 @@ private static final class Fixed implements Dosage {
*/
Fixed(final Dosage dsg, final List<Map<String, AttributeValue>> items) {
this.prev = dsg;
this.list = new Array<Map<String, AttributeValue>>(items);
this.list = new Array<>(items);
}
@Override
public List<Map<String, AttributeValue>> items() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/jcabi/dynamo/AwsTable.java
Expand Up @@ -120,7 +120,7 @@ public Item put(final Map<String, AttributeValue> attributes)
this.frame(),
this.self,
new Attributes(attributes).only(this.keys()),
new Array<String>(this.keys())
new Array<>(this.keys())
);
} catch (final AmazonClientException ex) {
throw new IOException(
Expand Down Expand Up @@ -163,7 +163,7 @@ public Collection<String> keys() throws IOException {
final DescribeTableResult result = aws.describeTable(
new DescribeTableRequest().withTableName(this.self)
);
final Collection<String> keys = new LinkedList<String>();
final Collection<String> keys = new LinkedList<>();
for (final KeySchemaElement key
: result.getTable().getKeySchema()) {
keys.add(key.getAttributeName());
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/jcabi/dynamo/Conditions.java
Expand Up @@ -80,7 +80,7 @@ public final class Conditions implements Map<String, Condition> {
* Public ctor.
*/
public Conditions() {
this(new ArrayMap<String, Condition>());
this(new ArrayMap<>());
}

/**
Expand Down Expand Up @@ -170,7 +170,7 @@ public Conditions with(final String name, final Object value) {
*/
public Conditions withAttributes(final Map<String, AttributeValue> map) {
final ConcurrentMap<String, Condition> cnds =
new ConcurrentHashMap<String, Condition>(map.size());
new ConcurrentHashMap<>(map.size());
for (final Map.Entry<String, AttributeValue> entry : map.entrySet()) {
cnds.put(
entry.getKey(),
Expand All @@ -192,7 +192,7 @@ public Conditions with(final Map<String, Condition> map) {
@Override
public String toString() {
final Collection<String> terms =
new ArrayList<String>(this.conds.size());
new ArrayList<>(this.conds.size());
for (final Map.Entry<String, Condition> cond : this.conds.entrySet()) {
terms.add(
String.format(
Expand Down Expand Up @@ -282,14 +282,14 @@ public void clear() {
private static ArrayMap<String, Condition> array(
final Map<String, Condition> map) {
final ConcurrentMap<String, Condition> cnds =
new ConcurrentHashMap<String, Condition>(map.size());
new ConcurrentHashMap<>(map.size());
for (final Map.Entry<String, Condition> entry : map.entrySet()) {
cnds.put(
entry.getKey(),
entry.getValue()
);
}
return new ArrayMap<String, Condition>(cnds);
return new ArrayMap<>(cnds);
}

}
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/dynamo/Dosage.java
Expand Up @@ -76,7 +76,7 @@ public interface Dosage {
final class Empty implements Dosage {
@Override
public List<Map<String, AttributeValue>> items() {
return new ArrayList<Map<String, AttributeValue>>(0);
return new ArrayList<>(0);
}
@Override
public Dosage next() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/jcabi/dynamo/QueryValve.java
Expand Up @@ -103,7 +103,7 @@ public final class QueryValve implements Valve {
*/
public QueryValve() {
this(
Tv.TWENTY, true, new ArrayList<String>(0),
Tv.TWENTY, true, new ArrayList<>(0),
"", Select.SPECIFIC_ATTRIBUTES.toString(), true
);
}
Expand Down Expand Up @@ -136,7 +136,7 @@ public Dosage fetch(final Credentials credentials, final String table,
throws IOException {
final AmazonDynamoDB aws = credentials.aws();
try {
final Collection<String> attrs = new HashSet<String>(
final Collection<String> attrs = new HashSet<>(
Arrays.asList(this.attributes)
);
attrs.addAll(keys);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/jcabi/dynamo/ScanValve.java
Expand Up @@ -81,7 +81,7 @@ public final class ScanValve implements Valve {
* Public ctor.
*/
public ScanValve() {
this(Tv.HUNDRED, new ArrayList<String>(0));
this(Tv.HUNDRED, new ArrayList<>(0));
}

/**
Expand All @@ -101,7 +101,7 @@ public Dosage fetch(final Credentials credentials,
final Collection<String> keys) throws IOException {
final AmazonDynamoDB aws = credentials.aws();
try {
final Collection<String> attrs = new HashSet<String>(
final Collection<String> attrs = new HashSet<>(
Arrays.asList(this.attributes)
);
attrs.addAll(keys);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/dynamo/mock/MkItem.java
Expand Up @@ -122,7 +122,7 @@ public Map<String, AttributeValue> put(
public Map<String, AttributeValue> put(
final Map<String, AttributeValueUpdate> attrs) throws IOException {
final Map<String, AttributeValue> keys =
new HashMap<String, AttributeValue>(0);
new HashMap<>(0);
for (final String attr : this.data.keys(this.table)) {
keys.put(attr, this.attributes.get(attr));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/dynamo/retry/ReFrame.java
Expand Up @@ -123,7 +123,7 @@ public boolean contains(final Object obj) {
@Override
@RetryOnFailure(verbose = false, delay = Tv.FIVE, unit = TimeUnit.SECONDS)
public Iterator<Item> iterator() {
return new ReIterator<Item>(this.origin.iterator());
return new ReIterator<>(this.origin.iterator());
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/jcabi/dynamo/AwsItemTest.java
Expand Up @@ -56,12 +56,12 @@ public void comparesToItself() throws Exception {
MatcherAssert.assertThat(
new AwsItem(
creds, frame, table.name(),
new Attributes(), new Array<String>()
new Attributes(), new Array<>()
),
Matchers.equalTo(
new AwsItem(
creds, frame, table.name(),
new Attributes(), new Array<String>()
new Attributes(), new Array<>()
)
)
);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/jcabi/dynamo/AwsIteratorTest.java
Expand Up @@ -94,7 +94,7 @@ public void iteratesValve() throws IOException {
table
),
table, new Conditions(),
new ArrayList<String>(0), valve
new ArrayList<>(0), valve
);
for (int idx = 0; idx < Tv.TEN; ++idx) {
MatcherAssert.assertThat(iterator.hasNext(), Matchers.is(true));
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/jcabi/dynamo/QueryValveTest.java
Expand Up @@ -76,7 +76,7 @@ public void fetchesData() throws Exception {
).when(aws).query(Mockito.any(QueryRequest.class));
final Dosage dosage = valve.fetch(
credentials, "table",
new Conditions(), new ArrayList<String>(0)
new Conditions(), new ArrayList<>(0)
);
MatcherAssert.assertThat(dosage.hasNext(), Matchers.is(false));
MatcherAssert.assertThat(dosage.items(), Matchers.hasItem(item));
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/jcabi/dynamo/ScanValveTest.java
Expand Up @@ -76,7 +76,7 @@ public void fetchesData() throws Exception {
).when(aws).scan(Mockito.any(ScanRequest.class));
final Dosage dosage = valve.fetch(
credentials, "table",
new Conditions(), new ArrayList<String>(0)
new Conditions(), new ArrayList<>(0)
);
MatcherAssert.assertThat(dosage.hasNext(), Matchers.is(false));
MatcherAssert.assertThat(dosage.items(), Matchers.hasItem(item));
Expand Down

0 comments on commit dbcfd8c

Please sign in to comment.