org.thevortex.lighting.jinks.groups.Group.java Source code

Java tutorial

Introduction

Here is the source code for org.thevortex.lighting.jinks.groups.Group.java

Source

/*
 * Copyright (c) 2014 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.groups;

import java.util.Objects;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.thevortex.lighting.jinks.Member;
import org.thevortex.lighting.jinks.MemberParent;

/**
 * A group is a named collection whose members will either turn "on" or "off" with the others in the group.
 *
 * @author E. A. Graham Jr.
 */
public class Group extends MemberParent<GroupDesired, Group.GroupMember, Group> {
    // TODO group members do not have desired state!
    public static class GroupMember extends Member<GroupDesired> {
        protected Object[] blacklistedReadings;
        protected String hubId;
        protected String localId;

        //        @JsonIgnore
        public Object[] getBlacklistedReadings() {
            return blacklistedReadings;
        }

        public void setBlacklistedReadings(Object[] blacklistedReadings) {
            this.blacklistedReadings = blacklistedReadings;
        }

        public String getHubId() {
            return hubId;
        }

        public void setHubId(String hubId) {
            this.hubId = hubId;
        }

        public String getLocalId() {
            return localId;
        }

        public void setLocalId(String localId) {
            this.localId = localId;
        }
    }

    protected ReadingAggregation readingAggregation;
    protected String automationMode;

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

    public ReadingAggregation getReadingAggregation() {
        return readingAggregation;
    }

    public void setReadingAggregation(ReadingAggregation readingAggregation) {
        this.readingAggregation = readingAggregation;
    }

    public String getAutomationMode() {
        return automationMode;
    }

    public void setAutomationMode(String automationMode) {
        this.automationMode = automationMode;
    }

    @Override
    public boolean stateChanged(Group other) {
        boolean same = super.stateChanged(other) && Objects.equals(readingAggregation, other.readingAggregation)
                && Objects.equals(automationMode, other.automationMode);
        return !same;
    }
}