michael@0: /** michael@0: * Copyright (c) 2012, Ben Fortuna michael@0: * All rights reserved. michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions michael@0: * are met: michael@0: * michael@0: * o Redistributions of source code must retain the above copyright michael@0: * notice, this list of conditions and the following disclaimer. michael@0: * michael@0: * o Redistributions in binary form must reproduce the above copyright michael@0: * notice, this list of conditions and the following disclaimer in the michael@0: * documentation and/or other materials provided with the distribution. michael@0: * michael@0: * o Neither the name of Ben Fortuna nor the names of any other contributors michael@0: * may be used to endorse or promote products derived from this software michael@0: * without specific prior written permission. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS michael@0: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT michael@0: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR michael@0: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR michael@0: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, michael@0: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, michael@0: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR michael@0: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF michael@0: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING michael@0: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS michael@0: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. michael@0: */ michael@0: package net.fortuna.ical4j.model; michael@0: michael@0: import java.io.IOException; michael@0: import java.io.Serializable; michael@0: import java.net.URISyntaxException; michael@0: import java.text.ParseException; michael@0: import java.util.Iterator; michael@0: michael@0: import net.fortuna.ical4j.model.component.CalendarComponent; michael@0: import net.fortuna.ical4j.model.property.CalScale; michael@0: import net.fortuna.ical4j.model.property.Method; michael@0: import net.fortuna.ical4j.model.property.ProdId; michael@0: import net.fortuna.ical4j.model.property.Version; michael@0: import net.fortuna.ical4j.model.property.XProperty; michael@0: import net.fortuna.ical4j.util.CompatibilityHints; michael@0: import net.fortuna.ical4j.util.ComponentValidator; michael@0: import net.fortuna.ical4j.util.PropertyValidator; michael@0: import net.fortuna.ical4j.util.Strings; michael@0: michael@0: import org.apache.commons.lang.builder.EqualsBuilder; michael@0: import org.apache.commons.lang.builder.HashCodeBuilder; michael@0: michael@0: /** michael@0: * $Id$ [Apr 5, 2004] michael@0: * michael@0: * Defines an iCalendar calendar. michael@0: * michael@0: *
michael@0:  *    4.6 Calendar Components
michael@0:  *    
michael@0:  *       The body of the iCalendar object consists of a sequence of calendar
michael@0:  *       properties and one or more calendar components. The calendar
michael@0:  *       properties are attributes that apply to the calendar as a whole. The
michael@0:  *       calendar components are collections of properties that express a
michael@0:  *       particular calendar semantic. For example, the calendar component can
michael@0:  *       specify an event, a to-do, a journal entry, time zone information, or
michael@0:  *       free/busy time information, or an alarm.
michael@0:  *    
michael@0:  *       The body of the iCalendar object is defined by the following
michael@0:  *       notation:
michael@0:  *    
michael@0:  *         icalbody   = calprops component
michael@0:  *    
michael@0:  *         calprops   = 2*(
michael@0:  *    
michael@0:  *                    ; 'prodid' and 'version' are both REQUIRED,
michael@0:  *                    ; but MUST NOT occur more than once
michael@0:  *    
michael@0:  *                    prodid /version /
michael@0:  *    
michael@0:  *                    ; 'calscale' and 'method' are optional,
michael@0:  *                    ; but MUST NOT occur more than once
michael@0:  *    
michael@0:  *                    calscale        /
michael@0:  *                    method          /
michael@0:  *    
michael@0:  *                    x-prop
michael@0:  *    
michael@0:  *                    )
michael@0:  *    
michael@0:  *         component  = 1*(eventc / todoc / journalc / freebusyc /
michael@0:  *                    / timezonec / iana-comp / x-comp)
michael@0:  *    
michael@0:  *         iana-comp  = "BEGIN" ":" iana-token CRLF
michael@0:  *    
michael@0:  *                      1*contentline
michael@0:  *    
michael@0:  *                      "END" ":" iana-token CRLF
michael@0:  *    
michael@0:  *         x-comp     = "BEGIN" ":" x-name CRLF
michael@0:  *    
michael@0:  *                      1*contentline
michael@0:  *    
michael@0:  *                      "END" ":" x-name CRLF
michael@0:  * 
michael@0: * michael@0: * Example 1 - Creating a new calendar: michael@0: * michael@0: *

michael@0:  * Calendar calendar = new Calendar();
michael@0:  * calendar.getProperties().add(new ProdId("-//Ben Fortuna//iCal4j 1.0//EN"));
michael@0:  * calendar.getProperties().add(Version.VERSION_2_0);
michael@0:  * calendar.getProperties().add(CalScale.GREGORIAN);
michael@0:  * 
michael@0:  * // Add events, etc..
michael@0:  * 
michael@0: * michael@0: * @author Ben Fortuna michael@0: */ michael@0: public class Calendar implements Serializable { michael@0: michael@0: private static final long serialVersionUID = -1654118204678581940L; michael@0: michael@0: /** michael@0: * Begin token. michael@0: */ michael@0: public static final String BEGIN = "BEGIN"; michael@0: michael@0: /** michael@0: * Calendar token. michael@0: */ michael@0: public static final String VCALENDAR = "VCALENDAR"; michael@0: michael@0: /** michael@0: * End token. michael@0: */ michael@0: public static final String END = "END"; michael@0: michael@0: private PropertyList properties; michael@0: michael@0: private ComponentList components; michael@0: michael@0: /** michael@0: * Default constructor. michael@0: */ michael@0: public Calendar() { michael@0: this(new PropertyList(), new ComponentList()); michael@0: } michael@0: michael@0: /** michael@0: * Constructs a new calendar with no properties and the specified components. michael@0: * @param components a list of components to add to the calendar michael@0: */ michael@0: public Calendar(final ComponentList components) { michael@0: this(new PropertyList(), components); michael@0: } michael@0: michael@0: /** michael@0: * Constructor. michael@0: * @param p a list of properties michael@0: * @param c a list of components michael@0: */ michael@0: public Calendar(final PropertyList p, final ComponentList c) { michael@0: this.properties = p; michael@0: this.components = c; michael@0: } michael@0: michael@0: /** michael@0: * Creates a deep copy of the specified calendar. michael@0: * @param c the calendar to copy michael@0: * @throws IOException where an error occurs reading calendar data michael@0: * @throws ParseException where calendar parsing fails michael@0: * @throws URISyntaxException where an invalid URI string is encountered michael@0: */ michael@0: public Calendar(Calendar c) throws ParseException, IOException, michael@0: URISyntaxException { michael@0: michael@0: this(new PropertyList(c.getProperties()), new ComponentList(c michael@0: .getComponents())); michael@0: } michael@0: michael@0: /** michael@0: * {@inheritDoc} michael@0: */ michael@0: public final String toString() { michael@0: final StringBuffer buffer = new StringBuffer(); michael@0: buffer.append(BEGIN); michael@0: buffer.append(':'); michael@0: buffer.append(VCALENDAR); michael@0: buffer.append(Strings.LINE_SEPARATOR); michael@0: buffer.append(getProperties()); michael@0: buffer.append(getComponents()); michael@0: buffer.append(END); michael@0: buffer.append(':'); michael@0: buffer.append(VCALENDAR); michael@0: buffer.append(Strings.LINE_SEPARATOR); michael@0: michael@0: return buffer.toString(); michael@0: } michael@0: michael@0: /** michael@0: * @return Returns the components. michael@0: */ michael@0: public final ComponentList getComponents() { michael@0: return components; michael@0: } michael@0: michael@0: /** michael@0: * Convenience method for retrieving a list of named components. michael@0: * @param name name of components to retrieve michael@0: * @return a component list containing only components with the specified name michael@0: */ michael@0: public final ComponentList getComponents(final String name) { michael@0: return getComponents().getComponents(name); michael@0: } michael@0: michael@0: /** michael@0: * Convenience method for retrieving a named component. michael@0: * @param name name of the component to retrieve michael@0: * @return the first matching component in the component list with the specified name michael@0: */ michael@0: public final Component getComponent(final String name) { michael@0: return getComponents().getComponent(name); michael@0: } michael@0: michael@0: /** michael@0: * @return Returns the properties. michael@0: */ michael@0: public final PropertyList getProperties() { michael@0: return properties; michael@0: } michael@0: michael@0: /** michael@0: * Convenience method for retrieving a list of named properties. michael@0: * @param name name of properties to retrieve michael@0: * @return a property list containing only properties with the specified name michael@0: */ michael@0: public final PropertyList getProperties(final String name) { michael@0: return getProperties().getProperties(name); michael@0: } michael@0: michael@0: /** michael@0: * Convenience method for retrieving a named property. michael@0: * @param name name of the property to retrieve michael@0: * @return the first matching property in the property list with the specified name michael@0: */ michael@0: public final Property getProperty(final String name) { michael@0: return getProperties().getProperty(name); michael@0: } michael@0: michael@0: /** michael@0: * Perform validation on the calendar, its properties and its components in its current state. michael@0: * @throws ValidationException where the calendar is not in a valid state michael@0: */ michael@0: public final void validate() throws ValidationException { michael@0: validate(true); michael@0: } michael@0: michael@0: /** michael@0: * Perform validation on the calendar in its current state. michael@0: * @param recurse indicates whether to validate the calendar's properties and components michael@0: * @throws ValidationException where the calendar is not in a valid state michael@0: */ michael@0: public void validate(final boolean recurse) throws ValidationException { michael@0: // 'prodid' and 'version' are both REQUIRED, michael@0: // but MUST NOT occur more than once michael@0: PropertyValidator.getInstance().assertOne(Property.PRODID, properties); michael@0: PropertyValidator.getInstance().assertOne(Property.VERSION, properties); michael@0: michael@0: if (!CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { michael@0: // require VERSION:2.0 for RFC2445.. michael@0: if (!Version.VERSION_2_0.equals(getProperty(Property.VERSION))) { michael@0: throw new ValidationException("Unsupported Version: " + getProperty(Property.VERSION).getValue()); michael@0: } michael@0: } michael@0: michael@0: // 'calscale' and 'method' are optional, michael@0: // but MUST NOT occur more than once michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.CALSCALE, michael@0: properties); michael@0: PropertyValidator.getInstance().assertOneOrLess(Property.METHOD, michael@0: properties); michael@0: michael@0: // must contain at least one component michael@0: if (getComponents().isEmpty()) { michael@0: throw new ValidationException( michael@0: "Calendar must contain at least one component"); michael@0: } michael@0: michael@0: // validate properties.. michael@0: for (final Iterator i = getProperties().iterator(); i.hasNext();) { michael@0: final Property property = (Property) i.next(); michael@0: michael@0: if (!(property instanceof XProperty) michael@0: && !property.isCalendarProperty()) { michael@0: throw new ValidationException("Invalid property: " michael@0: + property.getName()); michael@0: } michael@0: } michael@0: michael@0: // validate components.. michael@0: for (final Iterator i = getComponents().iterator(); i.hasNext();) { michael@0: final Component component = (Component) i.next(); michael@0: if (!(component instanceof CalendarComponent)) { michael@0: throw new ValidationException("Not a valid calendar component: " + component.getName()); michael@0: } michael@0: } michael@0: michael@0: // if (!CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { michael@0: // validate method.. michael@0: final Method method = (Method) getProperty(Property.METHOD); michael@0: if (Method.PUBLISH.equals(method)) { michael@0: if (getComponent(Component.VEVENT) != null) { michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: michael@0: if (!CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION)) { michael@0: ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: } michael@0: } michael@0: else if (getComponent(Component.VFREEBUSY) != null) { michael@0: ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTIMEZONE, getComponents()); michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VTODO) != null) { michael@0: // ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VEVENT, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VJOURNAL) != null) { michael@0: // ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VEVENT, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: } michael@0: } michael@0: else if (Method.REQUEST.equals(getProperty(Property.METHOD))) { michael@0: if (getComponent(Component.VEVENT) != null) { michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VFREEBUSY) != null) { michael@0: ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTIMEZONE, getComponents()); michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VTODO) != null) { michael@0: // ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VEVENT, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: } michael@0: } michael@0: else if (Method.REPLY.equals(getProperty(Property.METHOD))) { michael@0: if (getComponent(Component.VEVENT) != null) { michael@0: ComponentValidator.assertOneOrLess(Component.VTIMEZONE, getComponents()); michael@0: michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VFREEBUSY) != null) { michael@0: ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTIMEZONE, getComponents()); michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VTODO) != null) { michael@0: ComponentValidator.assertOneOrLess(Component.VTIMEZONE, getComponents()); michael@0: michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VEVENT, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: } michael@0: } michael@0: else if (Method.ADD.equals(getProperty(Property.METHOD))) { michael@0: if (getComponent(Component.VEVENT) != null) { michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VTODO) != null) { michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VEVENT, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VJOURNAL) != null) { michael@0: ComponentValidator.assertOneOrLess(Component.VTIMEZONE, getComponents()); michael@0: michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VEVENT, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: } michael@0: } michael@0: else if (Method.CANCEL.equals(getProperty(Property.METHOD))) { michael@0: if (getComponent(Component.VEVENT) != null) { michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VTODO) != null) { michael@0: ComponentValidator.assertOneOrLess(Component.VTIMEZONE, getComponents()); michael@0: michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VEVENT, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VJOURNAL) != null) { michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VEVENT, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: } michael@0: } michael@0: else if (Method.REFRESH.equals(getProperty(Property.METHOD))) { michael@0: if (getComponent(Component.VEVENT) != null) { michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VTODO) != null) { michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VEVENT, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTIMEZONE, getComponents()); michael@0: } michael@0: } michael@0: else if (Method.COUNTER.equals(getProperty(Property.METHOD))) { michael@0: if (getComponent(Component.VEVENT) != null) { michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VTODO) != null) { michael@0: ComponentValidator.assertOneOrLess(Component.VTIMEZONE, getComponents()); michael@0: michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VEVENT, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: } michael@0: } michael@0: else if (Method.DECLINE_COUNTER.equals(getProperty(Property.METHOD))) { michael@0: if (getComponent(Component.VEVENT) != null) { michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTODO, getComponents()); michael@0: ComponentValidator.assertNone(Component.VTIMEZONE, getComponents()); michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: } michael@0: else if (getComponent(Component.VTODO) != null) { michael@0: ComponentValidator.assertNone(Component.VALARM, getComponents()); michael@0: ComponentValidator.assertNone(Component.VFREEBUSY, getComponents()); michael@0: // ComponentValidator.assertNone(Component.VEVENT, getComponents()); michael@0: ComponentValidator.assertNone(Component.VJOURNAL, getComponents()); michael@0: } michael@0: } michael@0: // } michael@0: michael@0: // perform ITIP validation on components.. michael@0: if (method != null) { michael@0: for (final Iterator i = getComponents().iterator(); i.hasNext();) { michael@0: final CalendarComponent component = (CalendarComponent) i.next(); michael@0: component.validate(method); michael@0: } michael@0: } michael@0: michael@0: if (recurse) { michael@0: validateProperties(); michael@0: validateComponents(); michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * Invoke validation on the calendar properties in its current state. michael@0: * @throws ValidationException where any of the calendar properties is not in a valid state michael@0: */ michael@0: private void validateProperties() throws ValidationException { michael@0: for (final Iterator i = getProperties().iterator(); i.hasNext();) { michael@0: final Property property = (Property) i.next(); michael@0: property.validate(); michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * Invoke validation on the calendar components in its current state. michael@0: * @throws ValidationException where any of the calendar components is not in a valid state michael@0: */ michael@0: private void validateComponents() throws ValidationException { michael@0: for (final Iterator i = getComponents().iterator(); i.hasNext();) { michael@0: final Component component = (Component) i.next(); michael@0: component.validate(); michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * Returns the mandatory prodid property. michael@0: * @return the PRODID property, or null if property doesn't exist michael@0: */ michael@0: public final ProdId getProductId() { michael@0: return (ProdId) getProperty(Property.PRODID); michael@0: } michael@0: michael@0: /** michael@0: * Returns the mandatory version property. michael@0: * @return the VERSION property, or null if property doesn't exist michael@0: */ michael@0: public final Version getVersion() { michael@0: return (Version) getProperty(Property.VERSION); michael@0: } michael@0: michael@0: /** michael@0: * Returns the optional calscale property. michael@0: * @return the CALSCALE property, or null if property doesn't exist michael@0: */ michael@0: public final CalScale getCalendarScale() { michael@0: return (CalScale) getProperty(Property.CALSCALE); michael@0: } michael@0: michael@0: /** michael@0: * Returns the optional method property. michael@0: * @return the METHOD property, or null if property doesn't exist michael@0: */ michael@0: public final Method getMethod() { michael@0: return (Method) getProperty(Property.METHOD); michael@0: } michael@0: michael@0: /** michael@0: * {@inheritDoc} michael@0: */ michael@0: public final boolean equals(final Object arg0) { michael@0: if (arg0 instanceof Calendar) { michael@0: final Calendar calendar = (Calendar) arg0; michael@0: return new EqualsBuilder().append(getProperties(), calendar.getProperties()) michael@0: .append(getComponents(), calendar.getComponents()).isEquals(); michael@0: } michael@0: return super.equals(arg0); michael@0: } michael@0: michael@0: /** michael@0: * {@inheritDoc} michael@0: */ michael@0: public final int hashCode() { michael@0: return new HashCodeBuilder().append(getProperties()).append( michael@0: getComponents()).toHashCode(); michael@0: } michael@0: }