001package org.clafer.ast; 002 003import org.clafer.common.Check; 004 005/** 006 * 007 * @author jimmy 008 */ 009public class AstRef { 010 011 private final AstClafer sourceType; 012 private final AstClafer targetType; 013 private final boolean unique; 014 015 AstRef(AstClafer sourceType, AstClafer targetType, boolean unique) { 016 this.sourceType = Check.notNull(sourceType); 017 this.targetType = Check.notNull(targetType); 018 this.unique = unique; 019 } 020 021 public AstClafer getSourceType() { 022 return sourceType; 023 } 024 025 public AstClafer getTargetType() { 026 return targetType; 027 } 028 029 public boolean isUnique() { 030 return unique; 031 } 032 033 @Override 034 public boolean equals(Object obj) { 035 return this == obj; 036 } 037 038 @Override 039 public int hashCode() { 040 return sourceType.hashCode() ^ targetType.hashCode(); 041 } 042 043 @Override 044 public String toString() { 045 return sourceType.getName() + " . ref::" + targetType; 046 } 047}