public class IdentifiableObject extends Object
Modifier | Constructor and Description |
---|---|
protected |
IdentifiableObject(String prefix,
long id,
String name)
Constructs an identifiable object with the specified prefix, id and name.
|
Modifier and Type | Method and Description |
---|---|
long |
getId()
Returns the unique id of this object.
|
String |
getName()
Returns the name of this object.
|
String |
toString()
Returns a string representation of this object.
|
protected IdentifiableObject(String prefix, long id, String name)
prefix
- the prefix used to generate string representation of this
objectid
- the id of the objectname
- the name of the object or null
if the name should
be auto generatedpublic String toString()
a. if the name argument passed to the constructor was specified
return prefix + name;b. if the name argument passed to the constructor was
null
return prefix + Long.toString(id);
public final long getId()
public final String getName()
null
it returns auto generated name that is formatted in
the following way:
return prefix + Long.toString(id);
Copyright © 2017–2022 SNF4J.ORG. All rights reserved.