/** * An atomic operation that prepends a value to an existing bin value. Bin value must be a string type. * * @param fieldName Name of the bin or, if mapped Class was provided, name of the mapped field * @param value Value to prepend to the bin value. */ public SingleKeyCommander<T> prepend(String fieldName, String value) { String binName = mapper != null ? mapper.getBinName(fieldName) : fieldName; operations.add(Operation.prepend(new Bin(binName, value))); return this; }
@SuppressWarnings("unchecked") @Override public <T> T prepend(T objectToPrependTo, Map<String, String> values) { Assert.notNull(objectToPrependTo, "Object to prepend to must not be null!"); try { AerospikeWriteData data = AerospikeWriteData.forWrite(); converter.write(objectToPrependTo, data); Operation[] ops = new Operation[values.size() + 1]; int x = 0; for (Map.Entry<String, String> entry : values.entrySet()) { Bin newBin = new Bin(entry.getKey(), entry.getValue()); ops[x] = Operation.prepend(newBin); x++; } ops[x] = Operation.get(); Record record = this.client.operate(null, data.getKey(), ops); return mapToEntity(data.getKey(), (Class<T>) objectToPrependTo.getClass(), record); } catch (AerospikeException o_O) { DataAccessException translatedException = exceptionTranslator .translateExceptionIfPossible(o_O); throw translatedException == null ? o_O : translatedException; } }
@SuppressWarnings("unchecked") @Override public <T> T prepend(T objectToPrependTo, String fieldName, String value) { Assert.notNull(objectToPrependTo, "Object to prepend to must not be null!"); try { AerospikeWriteData data = AerospikeWriteData.forWrite(); converter.write(objectToPrependTo, data); Record record = this.client.operate(null, data.getKey(), Operation.prepend(new Bin(fieldName, value)), Operation.get(fieldName)); return mapToEntity(data.getKey(), (Class<T>) objectToPrependTo.getClass(), record); } catch (AerospikeException o_O) { DataAccessException translatedException = exceptionTranslator .translateExceptionIfPossible(o_O); throw translatedException == null ? o_O : translatedException; } }