All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hawkular.client.api.Notification Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2014-2017 Red Hat, Inc. and/or its affiliates
 * and other contributors as indicated by the @author tags.
 *
 * 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.hawkular.client.api;

import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonInclude;

import io.swagger.annotations.ApiModel;

/**
 * @author Jay Shaughnessy
 */

@ApiModel(description = "A general notification supplying the type and a map of properties.")
public class Notification {

    @JsonInclude
    NotificationType type;

    @JsonInclude
    Map properties;

    // For JSON deserialization
    public Notification() {
    }

    public Notification(NotificationType type, Map properties) {
        super();
        this.type = type;
        this.properties = properties;
    }

    public NotificationType getType() {
        return type;
    }

    public void setType(NotificationType type) {
        this.type = type;
    }

    public void addProperty(String name, String value) {
        if (null == name || null == value) {
            throw new IllegalArgumentException("Property must have non-null name and value");
        }
        getProperties().put(name, value);
    }

    public Map getProperties() {
        if (null == properties) {
            properties = new HashMap<>();
        }

        return properties;
    }

    public void setProperties(Map properties) {
        this.properties = properties;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((properties == null) ? 0 : properties.hashCode());
        result = prime * result + ((type == null) ? 0 : type.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Notification other = (Notification) obj;
        if (properties == null) {
            if (other.properties != null)
                return false;
        } else if (!properties.equals(other.properties))
            return false;
        if (type != other.type)
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "Notification [type=" + type + ", properties=" + properties + "]";
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy