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

com.google.sitebricks.stat.MemberAnnotatedWithAtStat Maven / Gradle / Ivy

/**
 * Copyright (C) 2011 Google Inc.
 *
 * 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 com.google.sitebricks.stat;

import com.google.common.base.Objects;

import java.lang.reflect.Member;

/**
 * This is a value object that contains information about a member
 * annotated with {@link Stat}.
 *
 * @author [email protected] (Fred Faber)
 */
final class MemberAnnotatedWithAtStat {
  final Stat stat;
  final Member member;

  MemberAnnotatedWithAtStat(Stat stat, Member member) {
    this.stat = stat;
    this.member = member;
  }

  Stat getStat() {
    return stat;
  }

  @SuppressWarnings("unchecked")
   T getMember() {
    return (T) member;
  }

  @Override public boolean equals(Object other) {
    if (!(other instanceof MemberAnnotatedWithAtStat)) {
      return false;
    }

    MemberAnnotatedWithAtStat otherAnnotatedMember =
        (MemberAnnotatedWithAtStat) other;
    return Objects.equal(this.member, otherAnnotatedMember.member)
        && Objects.equal(this.stat, otherAnnotatedMember.stat);
  }

  @Override public int hashCode() {
    return Objects.hashCode(stat, member);
  }

  @Override public String toString() {
    return Objects.toStringHelper(this)
        .add("Stat", stat)
        .add("Member", member)
        .toString();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy