@Override public Frame where(final String name, final String value) { return this.where(name, Conditions.equalTo(value)); }
@Override public Frame where(final String attr, final String value) { return this.where(attr, Conditions.equalTo(value)); }
@Override public Frame where(final String attr, final String value) { return this.where(attr, Conditions.equalTo(value)); }
@Override public Frame where(final String name, final String value) { return this.where(name, Conditions.equalTo(value)); }
/** * With these conditions. * @param map The conditions * @return New map of conditions */ public Conditions withAttributes(final Map<String, AttributeValue> map) { final ConcurrentMap<String, Condition> cnds = new ConcurrentHashMap<String, Condition>(map.size()); for (final Map.Entry<String, AttributeValue> entry : map.entrySet()) { cnds.put( entry.getKey(), Conditions.equalTo(entry.getValue()) ); } return new Conditions(this.conds.with(cnds)); }
/** * 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) { return Conditions.equalTo( new AttributeValue().withS(value.toString()) ); }
/** * With these conditions. * @param map The conditions * @return New map of conditions */ public Conditions withAttributes(final Map<String, AttributeValue> map) { final ConcurrentMap<String, Condition> cnds = new ConcurrentHashMap<String, Condition>(map.size()); for (final Map.Entry<String, AttributeValue> entry : map.entrySet()) { cnds.put( entry.getKey(), Conditions.equalTo(entry.getValue()) ); } return new Conditions(this.conds.with(cnds)); }
/** * 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) { return Conditions.equalTo( new AttributeValue().withS(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 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 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()) ); }
/** * With this condition. * @param name Attribute name * @param value The condition * @return New map of conditions * @since 0.18 */ public Conditions with(final String name, final Object value) { return new Conditions( this.conds.with( name, Conditions.equalTo(value) ) ); }
/** * With this condition. * @param name Attribute name * @param value The condition * @return New map of conditions * @since 0.18 */ public Conditions with(final String name, final Object value) { return new Conditions( this.conds.with( name, Conditions.equalTo(value) ) ); }
@Override @Cacheable(lifetime = 1, unit = TimeUnit.HOURS) public Counter get(final String name) { return new DyCounter( this.table.frame() .through(new QueryValve().withLimit(1)) .where(DyCounters.HASH, Conditions.equalTo(this.owner)) .where(DyCounters.RANGE, Conditions.equalTo(name)) .iterator() .next() ); }
@Override @Cacheable(lifetime = 1, unit = TimeUnit.HOURS) public Iterable<String> names() { return Iterables.transform( this.table.frame() .through(new QueryValve()) .where(DyCounters.HASH, Conditions.equalTo(this.owner)), new Function<Item, String>() { @Override public String apply(final Item item) { try { return item.get(DyCounters.RANGE).getS(); } catch (final IOException ex) { throw new IllegalStateException(ex); } } } ); } }
@Override @Cacheable(forever = true) public boolean exists() { return this.region.table(DefaultUser.TOKENS) .frame().through(new QueryValve()) .where(DefaultUser.HASH, Conditions.equalTo(this.name)) .iterator().hasNext(); }
@Override public Map<String, String> names() { final ImmutableMap.Builder<String, String> map = new ImmutableMap.Builder<String, String>(); Iterables.all( this.table.frame().through( new QueryValve().withAttributesToGet( DyLocks.ATTR_LABEL ) ).where(DyLocks.HASH, Conditions.equalTo(this.owner)), new Predicate<Item>() { @Override public boolean apply(final Item item) { try { map.put( item.get(DyLocks.RANGE).getS(), item.get(DyLocks.ATTR_LABEL).getS() ); } catch (final IOException ex) { throw new IllegalStateException(ex); } return true; } } ); return map.build(); }
@Override @Cacheable(lifetime = 1, unit = TimeUnit.HOURS) public String token() throws IOException { final Iterator<Item> items = this.region.table(DefaultUser.TOKENS) .frame().through(new QueryValve()) .where(DefaultUser.HASH, Conditions.equalTo(this.name)) .iterator(); final String token; if (items.hasNext()) { token = items.next().get(DefaultUser.ATTR_TOKEN).getS(); } else { this.refresh(); token = this.token(); } return token; }