| 1 | /* |
| 2 | * JTiger Unit Testing Framework for J2SE 1.5 |
| 3 | * Copyright (C) 2005 Tony Morris |
| 4 | * |
| 5 | * This software is licenced under the |
| 6 | * Common Public Licence version 1.0 |
| 7 | * http://www.opensource.org/licenses/cpl1.0.php |
| 8 | * |
| 9 | * You received a copy of this licence with this software. |
| 10 | */ |
| 11 | package org.jtiger.report.html; |
| 12 | |
| 13 | /** |
| 14 | * A bean that is used by {@link org.jtiger.report.html.HtmlFixtureResultsHandler the HTML result handler} to produce a report. |
| 15 | * |
| 16 | * @author %javadoc.author.tag% |
| 17 | * @version %version%<br/> |
| 18 | * <i>Build Number %build.number%</i><br/> |
| 19 | * <i>Build Time %build.time% CET (GMT + 1)</i> |
| 20 | */ |
| 21 | public final class FixtureResultBeanImpl implements FixtureResultBean |
| 22 | { |
| 23 | private static final long serialVersionUID = 2L; |
| 24 | |
| 25 | private String name; |
| 26 | private String href; |
| 27 | |
| 28 | /** |
| 29 | * Create a default <tt>FixtureResultBeanImpl</tt>. |
| 30 | */ |
| 31 | public FixtureResultBeanImpl() |
| 32 | { |
| 33 | |
| 34 | } |
| 35 | |
| 36 | FixtureResultBeanImpl(final String name, final String href) |
| 37 | { |
| 38 | this.name = name; |
| 39 | this.href = href; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Returns the name property of the bean. |
| 44 | * |
| 45 | * @return The name property of the bean. |
| 46 | */ |
| 47 | public String getName() |
| 48 | { |
| 49 | return name; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Sets the name property of the bean. |
| 54 | * |
| 55 | * @param name The name property of the bean. |
| 56 | */ |
| 57 | public void setName(final String name) |
| 58 | { |
| 59 | this.name = name; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Returns the href property of the bean. |
| 64 | * |
| 65 | * @return The href property of the bean. |
| 66 | */ |
| 67 | public String getHref() |
| 68 | { |
| 69 | return href; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Sets the href property of the bean. |
| 74 | * |
| 75 | * @param href The href property of the bean. |
| 76 | */ |
| 77 | public void setHref(final String href) |
| 78 | { |
| 79 | this.href = href; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Returns a <a href="%j2se.api.spec%/java/lang/String.html">java.lang.String</a> representation of the bean, which |
| 84 | * consists of the name property and the href proeprty. |
| 85 | * |
| 86 | * @return A <a href="%j2se.api.spec%/java/lang/String.html">java.lang.String</a> representation of the bean, which |
| 87 | * consists of the name property and the href proeprty. |
| 88 | */ |
| 89 | @Override |
| 90 | public String toString() |
| 91 | { |
| 92 | final StringBuilder sb = new StringBuilder(); |
| 93 | |
| 94 | sb.append('['); |
| 95 | sb.append(name); |
| 96 | sb.append("]["); |
| 97 | sb.append(href); |
| 98 | sb.append(']'); |
| 99 | |
| 100 | return sb.toString(); |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Compares two instance of <tt>FixtureResultBeanImpl</tt> returning <code>true</code> iff the name and href properties |
| 105 | * are equal, <code>false</code> otherwise. |
| 106 | * |
| 107 | * @param o An instance of <tt>FixtureResultBeanImpl</tt> to compare for equality. |
| 108 | * @return <code>true</code> iff the name and href properties are equal, <code>false</code> otherwise. |
| 109 | */ |
| 110 | @Override |
| 111 | public boolean equals(final Object o) |
| 112 | { |
| 113 | if(this == o) |
| 114 | { |
| 115 | return true; |
| 116 | } |
| 117 | |
| 118 | if(o == null || o.getClass() != FixtureResultBeanImpl.class) |
| 119 | { |
| 120 | return false; |
| 121 | } |
| 122 | |
| 123 | final FixtureResultBeanImpl f = (FixtureResultBeanImpl)o; |
| 124 | |
| 125 | return (name == null ? f.name == null : name.equals(f.name)) && |
| 126 | (href == null ? f.href == null : href.equals(f.href)); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Returns a hash code for this <tt>FixtureResultBeanImpl</tt> based on the name and href properties. |
| 131 | * |
| 132 | * @return A hash code for this <tt>FixtureResultBeanImpl</tt> based on the name and href properties. |
| 133 | */ |
| 134 | @Override |
| 135 | public int hashCode() |
| 136 | { |
| 137 | final int oddPrime = 461; |
| 138 | int result = 73; |
| 139 | |
| 140 | if(name != null) |
| 141 | { |
| 142 | result = result * oddPrime + name.hashCode(); |
| 143 | } |
| 144 | |
| 145 | if(href != null) |
| 146 | { |
| 147 | result = result * oddPrime + href.hashCode(); |
| 148 | } |
| 149 | |
| 150 | return result; |
| 151 | } |
| 152 | } |