/**
* Sets the committer for this {@code commit}. If no committer is explicitly
- * specified because this method is never called or called with {@code null}
- * value then the committer will be deduced from config info in repository,
- * with current time.
+ * specified because this method is never called then the committer will be
+ * deduced from config info in repository, with current time.
*
* @param name
* the name of the committer used for the {@code commit}
/**
* Sets the author for this {@code commit}. If no author is explicitly
- * specified because this method is never called or called with {@code null}
- * value then the author will be set to the committer or to the original
- * author when amending.
+ * specified because this method is never called then the author will be set
+ * to the committer or to the original author when amending.
*
* @param name
* the name of the author used for the {@code commit}
* @param repo
*/
public PersonIdent(final Repository repo) {
- final UserConfig config = repo.getConfig().get(UserConfig.KEY);
- name = config.getCommitterName();
- emailAddress = config.getCommitterEmail();
- when = SystemReader.getInstance().getCurrentTime();
- tzOffset = SystemReader.getInstance().getTimezone(when);
+ this(repo.getConfig().get(UserConfig.KEY));
}
/**
* @param aEmailAddress
*/
public PersonIdent(final String aName, final String aEmailAddress) {
- name = aName;
- emailAddress = aEmailAddress;
- when = SystemReader.getInstance().getCurrentTime();
- tzOffset = SystemReader.getInstance().getTimezone(when);
+ this(aName, aEmailAddress, SystemReader.getInstance().getCurrentTime());
}
/**
* local time
*/
public PersonIdent(final PersonIdent pi, final Date aWhen) {
- name = pi.getName();
- emailAddress = pi.getEmailAddress();
- when = aWhen.getTime();
- tzOffset = pi.tzOffset;
+ this(pi.getName(), pi.getEmailAddress(), aWhen.getTime(), pi.tzOffset);
}
/**
*/
public PersonIdent(final String aName, final String aEmailAddress,
final Date aWhen, final TimeZone aTZ) {
- name = aName;
- emailAddress = aEmailAddress;
- when = aWhen.getTime();
- tzOffset = aTZ.getOffset(when) / (60 * 1000);
+ this(aName, aEmailAddress, aWhen.getTime(), aTZ.getOffset(aWhen
+ .getTime()) / (60 * 1000));
}
/**
- * Construct a {@link PersonIdent}
+ * Copy a PersonIdent, but alter the clone's time stamp
*
- * @param aName
- * @param aEmailAddress
+ * @param pi
+ * original {@link PersonIdent}
* @param aWhen
* local time stamp
* @param aTZ
* time zone
*/
- public PersonIdent(final String aName, final String aEmailAddress,
- final long aWhen, final int aTZ) {
- name = aName;
- emailAddress = aEmailAddress;
- when = aWhen;
- tzOffset = aTZ;
+ public PersonIdent(final PersonIdent pi, final long aWhen, final int aTZ) {
+ this(pi.getName(), pi.getEmailAddress(), aWhen, aTZ);
+ }
+
+ private PersonIdent(final String aName, final String aEmailAddress,
+ long when) {
+ this(aName, aEmailAddress, when, SystemReader.getInstance()
+ .getTimezone(when));
+ }
+
+ private PersonIdent(final UserConfig config) {
+ this(config.getCommitterName(), config.getCommitterEmail());
}
/**
- * Copy a PersonIdent, but alter the clone's time stamp
+ * Construct a {@link PersonIdent}
*
- * @param pi
- * original {@link PersonIdent}
+ * @param aName
+ * @param aEmailAddress
* @param aWhen
* local time stamp
* @param aTZ
* time zone
*/
- public PersonIdent(final PersonIdent pi, final long aWhen, final int aTZ) {
- name = pi.getName();
- emailAddress = pi.getEmailAddress();
+ public PersonIdent(final String aName, final String aEmailAddress,
+ final long aWhen, final int aTZ) {
+ if (aName == null)
+ throw new IllegalArgumentException(
+ "Name of PersonIdent must not be null.");
+ if (aEmailAddress == null)
+ throw new IllegalArgumentException(
+ "E-mail address of PersonIdent must not be null.");
+ name = aName;
+ emailAddress = aEmailAddress;
when = aWhen;
tzOffset = aTZ;
}