Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package net.datenstrudel.bulbs.shared.domain.model.bulb;
  
  
A value object that represents the state of a bulb.
 
 @ApiModel(value = "Defines a single state of a single bulb.")
 public class BulbState implements ValueObject<BulbState>, Serializable {
 
     //~ Member(s) //////////////////////////////////////////////////////////////
     @ApiModelProperty(required = false, value = "Color of this state")
 	private Color<?> color;
     @ApiModelProperty(required = false, value = "whether the device is enabled")
     private boolean enabled;
    
    
Time in milliseconds that expires before application of this state
 
     private int transitionDelay = 0;
     
     //~ Construction ///////////////////////////////////////////////////////////
 	private BulbState(){
     }
     public BulbState(boolean enabled) {
         this. = enabled;
     }
     public BulbState(Color colorboolean enabled) {
         this. = color;
         this. = enabled;
     }
     public BulbState(Color colorboolean enabledint transitionDelay) {
         this. = color;
         this. = enabled;
         this. = transitionDelay;
     }
     
     public BulbState withNewEnabledState(boolean enabled){
         return new BulbState(this.enabledthis.);
     }
     public BulbState withNewColor(Color color){
         return new BulbState(colorthis.);
     }
     public BulbState withTransitionDelay(int transitionDelay){
         return new BulbState(transitionDelay);
     }
     public BulbState withColorAndTransitionDelay(Color colorint transitionDelay){
         return new BulbState(colortransitionDelay);
     }
    
Merge the updated state into this', returning a new object, leaving this as is

Parameters:
updated the new state to merge from
Returns:
new merged state
 
     public BulbState mergeUpdated(BulbState updated){
         BulbState res = this.withNewEnabledState(updated.getEnabled());
         if(updated.getColor() != null ) 
             res.setColor(updated.getColor());
         return res;
     }
 
     //~ Method(s) //////////////////////////////////////////////////////////////
     public Color getColor(){
 		return ;
 	}
 	public boolean getEnabled(){
 		return ;
 	}
     public int getTransitionDelay() {
         return ;
     }
     
     @Override
 	public boolean sameValueAs(BulbState other){
 		if(other == nullreturn false;
         return this.equals(other);
 	}
     @Override
     public int hashCode() {
         int hash = 7;
         hash = 67 * hash + (this. != null ? this..hashCode() : 0);
         hash = 67 * hash + (this. ? 1 : 0);
         hash = 67 * hash + this.;
         return hash;
     }
     @Override
     public boolean equals(Object obj) {
         if (obj == null) {
             return false;
         }
         if(this == objreturn true;
         
         if (getClass() != obj.getClass()) {
            return false;
        }
        final BulbState other = (BulbStateobj;
        if (this. != other.color && (this. == null || !this..equals(other.color))) {
            return false;
        }
        if (this. != other.enabled) {
            return false;
        }
        if (this. != other.transitionDelay) {
            return false;
        }
        return true;
    }
    @Override
    public String toString() {
        return "BulbState{" 
                + "color=" +  
                + ", enabled=" +  
                + ", transitionDelay=" + 
                + '}';
    }
    
    
    //~ Private Artifact(s) ////////////////////////////////////////////////////
    private void setColor(Color color) {
        this. = color;
    }
    private void setEnabled(boolean enabled) {
        this. = enabled;
    }
    private void setTransitionDelay(int transitionDelay) {
        this. = transitionDelay;
    }
    
New to GrepCode? Check out our FAQ X