/** * Executes the closure by calling the decorated transformer. * * @param input the input object */ @Override public void execute(final E input) { iTransformer.transform(input); }
/** * Transforms an object. * <p> * The transformer itself may throw an exception if necessary. * * @param object the object to transform * @return a transformed object */ protected E transform(final E object) { return transformer.transform(object); }
/** * Transforms a value. * <p> * The transformer itself may throw an exception if necessary. * * @param object the object to transform * @return the transformed object */ protected V transformValue(final U object) { return valueTransformer.transform(object); }
/** * Override to transform the value when using <code>setValue</code>. * * @param value the value to transform * @return the transformed value * @since 3.1 */ @Override protected V checkSetValue(final V value) { return valueTransformer.transform(value); }
/** * Transforms the input to result via each decorated transformer * * @param object the input object passed to the first transformer * @return the transformed result */ @Override public T transform(T object) { for (final Transformer<? super T, ? extends T> iTransformer : iTransformers) { object = iTransformer.transform(object); } return object; }
/** * Transforms a key. * <p> * The transformer itself may throw an exception if necessary. * * @param object the object to transform * @return the transformed object */ protected K transformKey(final J object) { return keyTransformer.transform(object); }
/** * Override to transform the value when using <code>setValue</code>. * * @param value the value to transform * @return the transformed value */ protected V checkSetValue(final U value) { return valueTransformer.transform(value); }
/** * Transforms the given object using the transformer. * If the transformer is null, the original object is returned as-is. * * @param source the object to transform * @return the transformed object */ protected O transform(final I source) { return transformer.transform(source); } }
/** * Transforms a value. * <p> * The transformer itself may throw an exception if necessary. * * @param object the object to transform * @return the transformed object */ protected V transformValue(final V object) { if (valueTransformer == null) { return object; } return valueTransformer.transform(object); }
/** * Transforms a value. * <p> * The transformer itself may throw an exception if necessary. * * @param object the object to transform * @return the transformed object */ protected V transformValue(final V object) { if (valueTransformer == null) { return object; } return valueTransformer.transform(object); }
/** * Transforms a key. * <p> * The transformer itself may throw an exception if necessary. * * @param object the object to transform * @return the transformed object */ protected K transformKey(final K object) { if (keyTransformer == null) { return object; } return keyTransformer.transform(object); }
/** * Transforms a key. * <p> * The transformer itself may throw an exception if necessary. * * @param object the object to transform * @return the transformed object */ protected K transformKey(final K object) { if (keyTransformer == null) { return object; } return keyTransformer.transform(object); }
/** * Returns the result of comparing the values from the transform operation. * * @param obj1 the first object to transform then compare * @param obj2 the second object to transform then compare * @return negative if obj1 is less, positive if greater, zero if equal */ @Override public int compare(final I obj1, final I obj2) { final O value1 = this.transformer.transform(obj1); final O value2 = this.transformer.transform(obj2); return this.decorated.compare(value1, value2); }
@Override @SuppressWarnings("unchecked") public V get(final Object key) { V v; return (((v = map.get(key)) != null) || map.containsKey(key)) ? v : value.transform((K) key); }
/** * Transforms the input using the true or false transformer based to the result of the predicate. * * @param input the input object to transform * @return the transformed result */ @Override public O transform(final I input) { if(iPredicate.evaluate(input)){ return iTrueTransformer.transform(input); } return iFalseTransformer.transform(input); }
@Override public V get(final Object key) { // create value for key if key is not currently in the map if (map.containsKey(key) == false) { @SuppressWarnings("unchecked") final K castKey = (K) key; final V value = factory.transform(castKey); map.put(castKey, value); return value; } return map.get(key); }
/** * Evaluates the predicate returning the result of the decorated predicate * once the input has been transformed * * @param object the input object which will be transformed * @return true if decorated predicate returns true */ @Override public boolean evaluate(final T object) { final T result = iTransformer.transform(object); return iPredicate.evaluate(result); }
/** * {@inheritDoc} * <p> * Note: uses the index for fast lookup */ @SuppressWarnings("unchecked") @Override public boolean contains(final Object object) { return index.containsKey(keyTransformer.transform((C) object)); }
/** * Removes an object from the index. * * @param object the object to remove */ private void removeFromIndex(final C object) { index.remove(keyTransformer.transform(object)); }
/** * Provides checking for adding the index. * * @param object the object to index * @throws IllegalArgumentException if the object maps to an existing key and the index * enforces a uniqueness constraint */ private void addToIndex(final C object) { final K key = keyTransformer.transform(object); if (uniqueIndex && index.containsKey(key)) { throw new IllegalArgumentException("Duplicate key in uniquely indexed collection."); } index.put(key, object); }