package propagation.impl;

import propagation.PropagationRule;
import propagation.StateItem;

public class StateItemImpl implements StateItem {
   // Can't use final now.
   private long itemId_;
   private long state_;
   private String name_;

   public StateItemImpl() {
   }

   public StateItemImpl(long itemId) {
      this.itemId_ = itemId;
      this.state_ = PropagationRule.STATE_CLEAR;
   }

   public long getState() {
      return this.state_;
   }

   public boolean setState(long state) {
      if (this.state_ != state) {
         if(itemId_ != 0) // don't print out summary items
            System.out.println("StateItem.setState(): id: " +itemId_ + " state changed from "
                    + state_ + " to " + state);
         state_ = state;
         return STATE_CHANGED;
      } else {
         return STATE_NOT_CHANGED;
      }
   }

   public long getItemId() {
      return this.itemId_;
   }

   public void setName(String name) { name_ = name; }

   public String getName() { return name_; }
}
