Skip to content

Commit

Permalink
[E4 Xpath] Unify and clean-up definitions of generic type arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell authored and praveen-skp committed Oct 14, 2024
1 parent c58c486 commit e5d62af
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2015 BestSolution.at and others.
* Copyright (c) 2010, 2024 BestSolution.at and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -20,18 +20,17 @@
/**
* Factory creating context using JXPath
*
* @param <Type>
* the object the XPath is created for
* @param <T> the object the XPath is created for
*/
public class JXPathContextFactoryImpl<Type> extends XPathContextFactory<Type> {
public class JXPathContextFactoryImpl<T> extends XPathContextFactory<T> {

@Override
public XPathContext newContext(XPathContext parentContext, Object contextBean) {
return new JXPathContextImpl(parentContext, contextBean);
}

@Override
public XPathContext newContext(Type contextBean) {
public XPathContext newContext(T contextBean) {
return new JXPathContextImpl(contextBean);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Object getValue(String xpath, Class<?> requiredType) {
}

@Override
public <Type> Iterator<Type> iterate(String xpath) {
public <T> Iterator<T> iterate(String xpath) {
return context.iterate(xpath);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2015 BestSolution.at and others.
* Copyright (c) 2010, 2024 BestSolution.at and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -46,15 +46,13 @@ public interface XPathContext {

/**
* Traverses the xpath and returns an Iterator of all results found for the
* path. If the xpath matches no properties in the graph, the Iterator will
* be empty, but not null.
* path. If the xpath matches no properties in the graph, the Iterator will be
* empty, but not null.
*
* @param <O>
* the expected object type
* @param <T> the expected object type
*
* @param xpath
* to iterate
* @param xpath to iterate
* @return Iterator&lt;Object&gt;
*/
<O> Iterator<O> iterate(String xpath);
<T> Iterator<T> iterate(String xpath);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2015 BestSolution.at and others.
* Copyright (c) 2010, 2024 BestSolution.at and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -18,39 +18,34 @@
/**
* Factory responsible to create an XPath-Context
*
* @param <Type>
* the object type the XPath is created for
* @param <T> the object type the XPath is created for
*/
public abstract class XPathContextFactory<Type extends Object> {
public abstract class XPathContextFactory<T> {

/**
* Creates a new XPathContext with the specified object as the root node.
*
* @param contextBean
* Object
* @param contextBean Object
* @return XPathContext
*/
public abstract XPathContext newContext(Type contextBean);
public abstract XPathContext newContext(T contextBean);

/**
* Creates a new XPathContext with the specified bean as the root node and
* the specified parent context. Variables defined in a parent context can
* be referenced in XPaths passed to the child context.
* Creates a new XPathContext with the specified bean as the root node and the
* specified parent context. Variables defined in a parent context can be
* referenced in XPaths passed to the child context.
*
* @param parentContext
* parent context
* @param contextBean
* Object
* @param parentContext parent context
* @param contextBean Object
* @return XPathContext
*/
public abstract XPathContext newContext(XPathContext parentContext, Type contextBean);
public abstract XPathContext newContext(XPathContext parentContext, T contextBean);

/**
* @param <Type>
* the object type the xpath is created for
* @param <T> the object type the xpath is created for
* @return Create a new XPath-Factory
*/
public static <Type> XPathContextFactory<Type> newInstance() {
public static <T> XPathContextFactory<T> newInstance() {
return new JXPathContextFactoryImpl<>();
}
}

0 comments on commit e5d62af

Please sign in to comment.