public class Eid extends Object implements Serializable
Exception identifier for all Eid Runtime Exceptions.
| Modifier and Type | Class and Description |
|---|---|
static interface |
Eid.UniqIdGenerator
It is used to generate unique ID for each EID object.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_FORMAT |
static String |
DEFAULT_MESSAGE_FORMAT |
static String |
DEFAULT_REF_FORMAT |
static Eid.UniqIdGenerator |
DEFAULT_UNIQ_ID_GENERATOR |
| Constructor and Description |
|---|
Eid(String id)
Constructor
|
Eid(String id,
String ref)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
String |
getId()
Getter for constant Exception ID
|
static String |
getMessageFormat()
Gets actually set message format
|
String |
getRef()
Get custom ref passed to Exception ID
|
String |
getUniq()
Gets unique generated string for this instance of Eid
|
String |
makeLogMessage(String logMessageFormat,
Object... parameters)
Makes a log message from this EID object
This method is for convenience of usage of EID in logging.
|
static String |
setFormat(String format)
Sets the actual format that will be used in
toString() method. |
static String |
setMessageFormat(String format)
Sets a format that will be used for all Eid exceptions when printing a detail message.
|
static String |
setRefFormat(String refFormat)
Sets the actual format that will be used in
toString() method |
static Eid.UniqIdGenerator |
setUniqIdGenerator(Eid.UniqIdGenerator uniqIdGenerator)
Sets the actual unique ID generator that will be used to generate IDs for all Eid objects.
|
String |
toString() |
public static final String DEFAULT_FORMAT
public static final String DEFAULT_REF_FORMAT
public static final String DEFAULT_MESSAGE_FORMAT
public static final Eid.UniqIdGenerator DEFAULT_UNIQ_ID_GENERATOR
public Eid(String id, @Nullable String ref)
id - the exception id, must be unique developer inserted string, from dateref - an optional referencepublic Eid(String id)
id - the exception id, must be unique developer inserted string, from datepublic static String setMessageFormat(String format)
Format must be non-null and contain two format specifiers "%s"
format - a format that will be used, must be non-null and contain two format specifiers "%s"IllegalArgumentException - if given format hasn't got two format specifiers "%s", or if given format was
nullpublic static String getMessageFormat()
public static Eid.UniqIdGenerator setUniqIdGenerator(Eid.UniqIdGenerator uniqIdGenerator)
uniqIdGenerator - new instance of unique ID generatorIllegalArgumentException - if given generator was nullpublic static String setFormat(String format)
toString() method. It will return previously used format.format - a format compliant with String.format(String, Object...) with 2 object argumentsIllegalArgumentException - if given format hasn't got two format specifiers "%s", or if given format was
nullpublic static String setRefFormat(String refFormat)
toString() methodrefFormat - a format compliant with String.format(String, Object...) with 3 object argumentsIllegalArgumentException - if given format hasn't got tree format specifiers "%s", or if given format was
nullpublic String makeLogMessage(@Nonnull String logMessageFormat, @Nonnull Object... parameters)
This method is for convenience of usage of EID in logging. You can use it like this:
log.debug(new Eid("20151025:202129").makeLogMessage("A request: %s", request));
logMessageFormat - a log message format as accepted by String.format(String, Object...)parameters - a parameters for logMessageFormat to by passed to String.format(String, Object...)public String getId()
public String getRef()
public String getUniq()
Copyright © 2015. All Rights Reserved.