org.thevortex.lighting.jinks.icons.WinkIcon.java Source code

Java tutorial

Introduction

Here is the source code for org.thevortex.lighting.jinks.icons.WinkIcon.java

Source

/*
 * Copyright (c) 2015 by the author(s).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.thevortex.lighting.jinks.icons;

import java.util.Objects;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.thevortex.lighting.jinks.WinkObject;

/**
 * An icon.
 *
 * @author E. A. Graham Jr.
 */
public class WinkIcon extends WinkObject<WinkIcon> {
    protected IconType iconType;
    protected String iosUrl;
    protected AndroidImages android;
    protected WinkImages images;
    protected byte[] imageBytes;

    @Override
    @JsonProperty("icon_id")
    public String getId() {
        return super.getId();
    }

    @JsonIgnore
    public Integer getIconId() {
        return null;
    }

    public IconType getIconType() {
        return iconType;
    }

    public void setIconType(IconType iconType) {
        this.iconType = iconType;
    }

    public String getIosUrl() {
        return iosUrl;
    }

    public void setIosUrl(String iosUrl) {
        this.iosUrl = iosUrl;
    }

    public AndroidImages getAndroid() {
        return android;
    }

    public void setAndroid(AndroidImages android) {
        this.android = android;
    }

    public WinkImages getImages() {
        return images;
    }

    public void setImages(WinkImages images) {
        this.images = images;
    }

    /**
     * @return the actual image
     */
    public byte[] getImageBytes() {
        return imageBytes;
    }

    public void setImageBytes(byte[] imageBytes) {
        this.imageBytes = imageBytes;
    }

    @Override
    public boolean stateChanged(WinkIcon that) {
        boolean same = iconType == that.iconType && Objects.equals(iosUrl, that.iosUrl)
                && Objects.equals(android, that.android) && Objects.equals(images, that.images);
        return !same;
    }
}