Messages Utils

Stores messages by context and severity.

License

License

GroupId

GroupId

io.github.jfermat
ArtifactId

ArtifactId

messages-utils
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Messages Utils
Stores messages by context and severity.
Project URL

Project URL

https://github.com/jfermat/messages-utils
Source Code Management

Source Code Management

https://github.com/jfermat/messages-utils

Download messages-utils

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.jfermat/messages-utils/ -->
<dependency>
    <groupId>io.github.jfermat</groupId>
    <artifactId>messages-utils</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.jfermat/messages-utils/
implementation 'io.github.jfermat:messages-utils:2.0.0'
// https://jarcasting.com/artifacts/io.github.jfermat/messages-utils/
implementation ("io.github.jfermat:messages-utils:2.0.0")
'io.github.jfermat:messages-utils:jar:2.0.0'
<dependency org="io.github.jfermat" name="messages-utils" rev="2.0.0">
  <artifact name="messages-utils" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.jfermat', module='messages-utils', version='2.0.0')
)
libraryDependencies += "io.github.jfermat" % "messages-utils" % "2.0.0"
[io.github.jfermat/messages-utils "2.0.0"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Messages Utils

Build Publishing artifacts Quality Gate Status Coverage Maintainability Rating

Requirements

Building the API client library requires:

  1. Java 11+
  2. Maven/Gradle

Installation

To install the Messages Utils library to your local Maven repository, simply execute:

mvn clean install

Maven users

Add this dependency to your project's POM:

<dependency>
  <groupId>io.github.jfermat</groupId>
  <artifactId>messages-utils</artifactId>
  <version>2.0.0</version>
  <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "io.github.jfermat:messages-utils:2.0.0"

##Getting Started

Please follow the installation instruction and execute the following Java code:

import io.github.jfermat.messages.Message;
import io.github.jfermat.messages.MessageBox;
import io.github.jfermat.messages.MessageContext;
import io.github.jfermat.messages.MessagesUtils;

import java.util.List;
import java.util.Map;

public class MessagesUtilsExample {

    public static void main(String[] args) {

        MessageContext context = MessagesUtils.defaultContext();

        context.addPrimaryMessage("This is a primary message uncategorized in the default context.");

        context.addSecondaryMessage("Messages", "This is a secondary severity message in the default context in the Messages category.");

        Map<MessageBox, List<Message>> messagesDefaultContext = context.messages();

        /* messagesDefaultContext value:
            MessageBox{category='Messages', severity='secondary'} = [
                Message{message='This is a secondary severity message in the default context in the Messages category.', args='{}'}
            ],
            MessageBox{category='null', severity='primary'} = [
                Message{message='This is a primary message uncategorized in the default context.', args='{}'}
            ]
         */

        MessageContext otherContext = MessagesUtils.context("other");

        otherContext.addInfoMessage(new Message() {
            @Override
            public String getMessage() {
                return "This is a info message uncategorized in the default context.";
            }

            @Override
            public Object[] getArgs() {
                return new Object[0];
            }
        });

        otherContext.addDangerMessage("Messages", new Message() {
            @Override
            public String getMessage() {
                return "This is a info message uncategorized in the default context.";
            }

            @Override
            public Object[] getArgs() {
                return new Object[0];
            }
        });

        Map<MessageBox, List<Message>> messagesOtherContext = context.messages();

        /* messagesOtherContext value:
            MessageBox{category='Messages', severity='secondary'} = [
                Message{message='This is a info message uncategorized in the default context.', args='{}'}
            ],
            MessageBox{category='null', severity='primary'} = [
                Message{message='This is a info message uncategorized in the default context.', args='{}'}
            ]
         */

        Map<String, MessageContext> allMessages = MessagesUtils.messages();
        /* allMessages value:
            "default" -> {
                MessageBox{category='Messages', severity='secondary'} = [
                    Message{message='This is a secondary severity message in the default context in the Messages category.', args='{}'}
                ],
                MessageBox{category='null', severity='primary'} = [
                    Message{message='This is a primary message uncategorized in the default context.', args='{}'}
                ]
            },
            "other" -> {
                MessageBox{category='Messages', severity='secondary'} = [
                    Message{message='This is a info message uncategorized in the default context.', args='{}'}
                ],
                MessageBox{category='null', severity='primary'} = [
                    Message{message='This is a info message uncategorized in the default context.', args='{}'}
                ]
            }
         */

    }
}

##Documentation

Javadoc: https://jfermat.github.io/docs/messages-utils

Versions

Version
2.0.0
1.0.0