001    /*
002     * The MIT License
003     * Copyright (c) 2012 Microsoft Corporation
004     *
005     * Permission is hereby granted, free of charge, to any person obtaining a copy
006     * of this software and associated documentation files (the "Software"), to deal
007     * in the Software without restriction, including without limitation the rights
008     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009     * copies of the Software, and to permit persons to whom the Software is
010     * furnished to do so, subject to the following conditions:
011     *
012     * The above copyright notice and this permission notice shall be included in
013     * all copies or substantial portions of the Software.
014     *
015     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021     * THE SOFTWARE.
022     */
023    
024    package microsoft.exchange.webservices.data.sync;
025    
026    import microsoft.exchange.webservices.data.attribute.EditorBrowsable;
027    import microsoft.exchange.webservices.data.core.service.ServiceObject;
028    import microsoft.exchange.webservices.data.core.enumeration.sync.ChangeType;
029    import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState;
030    import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException;
031    import microsoft.exchange.webservices.data.property.complex.ServiceId;
032    
033    /**
034     * Represents a change as returned by a synchronization operation.
035     */
036    @EditorBrowsable(state = EditorBrowsableState.Never)
037    public abstract class Change {
038    
039      /**
040       * The type of change.
041       */
042      private ChangeType changeType;
043    
044      /**
045       * The service object the change applies to.
046       */
047      private ServiceObject serviceObject;
048    
049      /**
050       * The Id of the service object the change applies to.
051       */
052      private ServiceId id;
053    
054      /**
055       * Initializes a new instance of Change.
056       */
057      protected Change() {
058      }
059    
060      /**
061       * Initializes a new instance of Change.
062       *
063       * @return the service id
064       */
065      public abstract ServiceId createId();
066    
067      /**
068       * Gets the type of the change.
069       *
070       * @return the change type
071       */
072      public ChangeType getChangeType() {
073        return this.changeType;
074      }
075    
076      /**
077       * sets the type of the change.
078       *
079       * @param changeType the new change type
080       */
081      public void setChangeType(ChangeType changeType) {
082        this.changeType = changeType;
083      }
084    
085      /**
086       * Gets  the service object the change applies to.
087       *
088       * @return the service object
089       */
090      public ServiceObject getServiceObject() {
091        return this.serviceObject;
092      }
093    
094      /**
095       * Sets the service object.
096       *
097       * @param serviceObject the new service object
098       */
099      public void setServiceObject(ServiceObject serviceObject) {
100        this.serviceObject = serviceObject;
101      }
102    
103      /**
104       * Gets the Id of the service object the change applies to.
105       *
106       * @return the id
107       * @throws ServiceLocalException the service local exception
108       */
109      public ServiceId getId() throws ServiceLocalException {
110        return this.getServiceObject() != null ? this.getServiceObject()
111            .getId() : this.id;
112      }
113    
114      /**
115       * Sets the id.
116       *
117       * @param id the new id
118       */
119      public void setId(ServiceId id) {
120        this.id = id;
121      }
122    }