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

org.jclouds.atmos.domain.UserMetadata Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.jclouds.atmos.domain;

import static shaded.com.google.common.base.Preconditions.checkNotNull;

import java.util.Map;
import java.util.Set;

import shaded.com.google.common.collect.Maps;
import shaded.com.google.common.collect.Sets;

/**
 * User metadata
 */
public class UserMetadata {
   private final Map metadata;
   private final Map listableMetadata;
   private final Set tags;
   private final Set listableTags;

   public UserMetadata(Map metadata, Map listableMetadata, Iterable tags,
         Iterable listableTags) {
      this.metadata = Maps.newLinkedHashMap(checkNotNull(metadata, "metadata"));
      this.listableMetadata = Maps.newLinkedHashMap(checkNotNull(listableMetadata, "listableMetadata"));
      this.tags = Sets.newLinkedHashSet(checkNotNull(tags, "tags"));
      this.listableTags = Sets.newLinkedHashSet(checkNotNull(listableTags, "listableTags"));
   }

   public UserMetadata() {
      this.metadata = Maps.newLinkedHashMap();
      this.listableMetadata = Maps.newLinkedHashMap();
      this.tags = Sets.newLinkedHashSet();
      this.listableTags = Sets.newLinkedHashSet();
   }

   public Map getMetadata() {
      return metadata;
   }

   public Map getListableMetadata() {
      return listableMetadata;
   }

   public Set getTags() {
      return tags;
   }

   public Set getListableTags() {
      return listableTags;
   }

   @Override
   public String toString() {
      return "[metadata=" + metadata + ", listableMetadata=" + listableMetadata + ", tags=" + tags + ", listableTags="
            + listableTags + "]";
   }

   @Override
   public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result + ((listableMetadata == null) ? 0 : listableMetadata.hashCode());
      result = prime * result + ((listableTags == null) ? 0 : listableTags.hashCode());
      result = prime * result + ((metadata == null) ? 0 : metadata.hashCode());
      result = prime * result + ((tags == null) ? 0 : tags.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;
      UserMetadata other = (UserMetadata) obj;
      if (listableMetadata == null) {
         if (other.listableMetadata != null)
            return false;
      } else if (!listableMetadata.equals(other.listableMetadata))
         return false;
      if (listableTags == null) {
         if (other.listableTags != null)
            return false;
      } else if (!listableTags.equals(other.listableTags))
         return false;
      if (metadata == null) {
         if (other.metadata != null)
            return false;
      } else if (!metadata.equals(other.metadata))
         return false;
      if (tags == null) {
         if (other.tags != null)
            return false;
      } else if (!tags.equals(other.tags))
         return false;
      return true;
   }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy