biweekly.property.EmailAlarm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of biweekly Show documentation
Show all versions of biweekly Show documentation
An iCalendar parser/writer library written in Java.
package biweekly.property;
import java.util.Map;
import biweekly.component.VAlarm;
/*
Copyright (c) 2013-2016, Michael Angstadt
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Defines an alarm that sends an email when triggered. It is recommended that
* the {@link VAlarm} component be used to create alarms.
* @author Michael Angstadt
* @see vCal 1.0 p.32
* @see VAlarm#email
*/
public class EmailAlarm extends VCalAlarmProperty {
private String email, note;
public EmailAlarm(String email) {
this.email = email;
}
/**
* Copy constructor.
* @param original the property to make a copy of
*/
public EmailAlarm(EmailAlarm original) {
super(original);
email = original.email;
note = original.note;
}
/**
* Gets the email address.
* @return the email address
*/
public String getEmail() {
return email;
}
/**
* Sets the email address.
* @param email the email address
*/
public void setEmail(String email) {
this.email = email;
}
/**
* Gets the note to send.
* @return the note
*/
public String getNote() {
return note;
}
/**
* Sets the note to send
* @param note the note
*/
public void setNote(String note) {
this.note = note;
}
@Override
protected Map toStringValues() {
Map values = super.toStringValues();
values.put("email", email);
values.put("note", note);
return values;
}
@Override
public EmailAlarm copy() {
return new EmailAlarm(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((email == null) ? 0 : email.hashCode());
result = prime * result + ((note == null) ? 0 : note.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!super.equals(obj)) return false;
EmailAlarm other = (EmailAlarm) obj;
if (email == null) {
if (other.email != null) return false;
} else if (!email.equals(other.email)) return false;
if (note == null) {
if (other.note != null) return false;
} else if (!note.equals(other.note)) return false;
return true;
}
}