001/* Copyright (C) 2013 TU Dortmund 002 * This file is part of LearnLib, http://www.learnlib.de/. 003 * 004 * LearnLib is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU Lesser General Public 006 * License version 3.0 as published by the Free Software Foundation. 007 * 008 * LearnLib is distributed in the hope that it will be useful, 009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 011 * Lesser General Public License for more details. 012 * 013 * You should have received a copy of the GNU Lesser General Public 014 * License along with LearnLib; if not, see 015 * <http://www.gnu.de/documents/lgpl.en.html>. 016 */ 017package de.learnlib.drivers.reflect; 018 019import java.util.Objects; 020 021/** 022 * Error output. 023 * 024 * @author falkhowar 025 */ 026public class Error extends AbstractMethodOutput { 027 028 private final Throwable cause; 029 030 private final String id; 031 032 public Error(Throwable cause) { 033 this.cause = cause; 034 this.id = cause.getClass().getSimpleName(); 035 } 036 037 @Override 038 public int hashCode() { 039 int hash = 5; 040 hash = 19 * hash + Objects.hashCode(this.id); 041 return hash; 042 } 043 044 @Override 045 public boolean equals(Object obj) { 046 if (obj == null) { 047 return false; 048 } 049 if (getClass() != obj.getClass()) { 050 return false; 051 } 052 final Error other = (Error) obj; 053 if (!Objects.equals(this.id, other.id)) { 054 return false; 055 } 056 return true; 057 } 058 059 /** 060 * @return the cause 061 */ 062 public Throwable getCause() { 063 return cause; 064 } 065 066 /** 067 * @return the id 068 */ 069 public String getId() { 070 return id; 071 } 072 073 @Override 074 public String toString() { 075 return "ERR_" + this.id; 076 } 077}