Author: lfryc(a)redhat.com
Date: 2010-07-23 10:14:55 -0400 (Fri, 23 Jul 2010)
New Revision: 18214
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/internal/
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/internal/NamedType.java
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
Log:
externalized NamedType
Added:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/internal/NamedType.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/internal/NamedType.java
(rev 0)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/internal/NamedType.java 2010-07-23
14:14:55 UTC (rev 18214)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.ftest.internal;
+
+import java.lang.annotation.Annotation;
+
+import org.richfaces.tests.metamer.ftest.annotations.Named;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+public class NamedType {
+ private Class<?> parameterType;
+ private String name;
+
+ public NamedType(Class<?> parameterType, String name) {
+ this.parameterType = parameterType;
+ this.name = name;
+ }
+
+ public NamedType(Class<?> parameterType, Annotation[] annotations) {
+ this.parameterType = parameterType;
+ for (Annotation annotation : annotations) {
+ if (annotation.annotationType() == Named.class) {
+ this.name = ((Named) annotation).value();
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "NamedType(" + parameterType.getSimpleName() + ", " +
name + ")";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((parameterType == null) ? 0 :
parameterType.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;
+ }
+ NamedType other = (NamedType) obj;
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ if (parameterType == null) {
+ if (other.parameterType != null) {
+ return false;
+ }
+ } else if (!parameterType.equals(other.parameterType)) {
+ return false;
+ }
+ return true;
+ }
+}
\ No newline at end of file
Modified:
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java
===================================================================
---
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-23
14:14:10 UTC (rev 18213)
+++
root/tests/metamer/trunk/ftest-source/src/main/java/org/richfaces/tests/metamer/ftest/richDataScroller/TestPagination.java 2010-07-23
14:14:55 UTC (rev 18214)
@@ -24,7 +24,6 @@
import static org.jboss.test.selenium.locator.LocatorFactory.id;
import static org.jboss.test.selenium.utils.URLUtils.buildUrl;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.net.URL;
@@ -42,6 +41,7 @@
import org.richfaces.tests.metamer.ftest.annotations.Inject;
import org.richfaces.tests.metamer.ftest.annotations.Named;
import org.richfaces.tests.metamer.ftest.annotations.Use;
+import org.richfaces.tests.metamer.ftest.internal.NamedType;
import org.richfaces.tests.metamer.ftest.richExtendedDataTable.AssertingDataScroller;
import org.richfaces.tests.metamer.ftest.richExtendedDataTable.DataTable;
import org.testng.annotations.AfterMethod;
@@ -204,77 +204,6 @@
return result;
}
- private class NamedType {
- private Class<?> parameterType;
- private String name;
-
- public NamedType(Class<?> parameterType, String name) {
- this.parameterType = parameterType;
- this.name = name;
- }
-
- public NamedType(Class<?> parameterType, Annotation[] annotations) {
- this.parameterType = parameterType;
- for (Annotation annotation : annotations) {
- if (annotation.annotationType() == Named.class) {
- this.name = ((Named) annotation).value();
- }
- }
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getOuterType().hashCode();
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((parameterType == null) ? 0 :
parameterType.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;
- }
- NamedType other = (NamedType) obj;
- if (!getOuterType().equals(other.getOuterType())) {
- return false;
- }
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (parameterType == null) {
- if (other.parameterType != null) {
- return false;
- }
- } else if (!parameterType.equals(other.parameterType)) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return "NamedType(" + parameterType.getSimpleName() + ",
" + name + ")";
- }
-
- private TestPagination getOuterType() {
- return TestPagination.this;
- }
-
- }
-
private List<? extends Object> getUseParameter(Class<?> parameterType,
Use use) {
if (parameterType == int.class || parameterType == Integer.class) {
return Arrays.asList(ArrayUtils.toObject(use.ints()));