You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@logging.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2017/06/01 17:30:04 UTC

[jira] [Updated] (LOG4J2-1930) Add forEach() methods to org.apache.logging.log4j.message.MapMessage

     [ https://issues.apache.org/jira/browse/LOG4J2-1930?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory updated LOG4J2-1930:
---------------------------------
    Description: 
Add {{forEach()}} methods to {{org.apache.logging.log4j.message.MapMessage}}:

{code:java}
    /**
     * Performs the given action for each key-value pair in this data structure
     * until all entries have been processed or the action throws an exception.
     * <p>
     * Some implementations may not support structural modifications (adding new elements or removing elements) while
     * iterating over the contents. In such implementations, attempts to add or remove elements from the
     * {@code BiConsumer}'s {@link BiConsumer#accept(Object, Object)} accept} method may cause a
     * {@code ConcurrentModificationException} to be thrown.
     * </p>
     *
     * @param action The action to be performed for each key-value pair in this collection
     * @param <V> type of the value
     * @throws java.util.ConcurrentModificationException some implementations may not support structural modifications
     *          to this data structure while iterating over the contents with {@link #forEach(BiConsumer)} or
     *          {@link #forEach(TriConsumer, Object)}.
     * @see ReadOnlyStringMap#forEach(BiConsumer)
     * @since 2.9
     */
    public <V> void forEach(final BiConsumer<String, ? super V> action) {
        data.forEach(action);
    }

    /**
     * Performs the given action for each key-value pair in this data structure
     * until all entries have been processed or the action throws an exception.
     * <p>
     * The third parameter lets callers pass in a stateful object to be modified with the key-value pairs,
     * so the TriConsumer implementation itself can be stateless and potentially reusable.
     * </p>
     * <p>
     * Some implementations may not support structural modifications (adding new elements or removing elements) while
     * iterating over the contents. In such implementations, attempts to add or remove elements from the
     * {@code TriConsumer}'s {@link TriConsumer#accept(Object, Object, Object) accept} method may cause a
     * {@code ConcurrentModificationException} to be thrown.
     * </p>
     *
     * @param action The action to be performed for each key-value pair in this collection
     * @param state the object to be passed as the third parameter to each invocation on the specified
     *          triconsumer
     * @param <V> type of the value
     * @param <S> type of the third parameter
     * @throws java.util.ConcurrentModificationException some implementations may not support structural modifications
     *          to this data structure while iterating over the contents with {@link #forEach(BiConsumer)} or
     *          {@link #forEach(TriConsumer, Object)}.
     * @see ReadOnlyStringMap#forEach(TriConsumer, Object)
     * @since 2.9
     */
    public <V, S> void forEach(final TriConsumer<String, ? super V, S> action, final S state) {
        data.forEach(action, state);
    }
{code}

  was:Add {{forEach()}} methods to {{org.apache.logging.log4j.message.MapMessage}}.


> Add forEach() methods to org.apache.logging.log4j.message.MapMessage
> --------------------------------------------------------------------
>
>                 Key: LOG4J2-1930
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1930
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: API
>            Reporter: Gary Gregory
>            Assignee: Gary Gregory
>
> Add {{forEach()}} methods to {{org.apache.logging.log4j.message.MapMessage}}:
> {code:java}
>     /**
>      * Performs the given action for each key-value pair in this data structure
>      * until all entries have been processed or the action throws an exception.
>      * <p>
>      * Some implementations may not support structural modifications (adding new elements or removing elements) while
>      * iterating over the contents. In such implementations, attempts to add or remove elements from the
>      * {@code BiConsumer}'s {@link BiConsumer#accept(Object, Object)} accept} method may cause a
>      * {@code ConcurrentModificationException} to be thrown.
>      * </p>
>      *
>      * @param action The action to be performed for each key-value pair in this collection
>      * @param <V> type of the value
>      * @throws java.util.ConcurrentModificationException some implementations may not support structural modifications
>      *          to this data structure while iterating over the contents with {@link #forEach(BiConsumer)} or
>      *          {@link #forEach(TriConsumer, Object)}.
>      * @see ReadOnlyStringMap#forEach(BiConsumer)
>      * @since 2.9
>      */
>     public <V> void forEach(final BiConsumer<String, ? super V> action) {
>         data.forEach(action);
>     }
>     /**
>      * Performs the given action for each key-value pair in this data structure
>      * until all entries have been processed or the action throws an exception.
>      * <p>
>      * The third parameter lets callers pass in a stateful object to be modified with the key-value pairs,
>      * so the TriConsumer implementation itself can be stateless and potentially reusable.
>      * </p>
>      * <p>
>      * Some implementations may not support structural modifications (adding new elements or removing elements) while
>      * iterating over the contents. In such implementations, attempts to add or remove elements from the
>      * {@code TriConsumer}'s {@link TriConsumer#accept(Object, Object, Object) accept} method may cause a
>      * {@code ConcurrentModificationException} to be thrown.
>      * </p>
>      *
>      * @param action The action to be performed for each key-value pair in this collection
>      * @param state the object to be passed as the third parameter to each invocation on the specified
>      *          triconsumer
>      * @param <V> type of the value
>      * @param <S> type of the third parameter
>      * @throws java.util.ConcurrentModificationException some implementations may not support structural modifications
>      *          to this data structure while iterating over the contents with {@link #forEach(BiConsumer)} or
>      *          {@link #forEach(TriConsumer, Object)}.
>      * @see ReadOnlyStringMap#forEach(TriConsumer, Object)
>      * @since 2.9
>      */
>     public <V, S> void forEach(final TriConsumer<String, ? super V, S> action, final S state) {
>         data.forEach(action, state);
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)