本文整理了Java中org.jvnet.tiger_types.Types.getBaseClass()
方法的一些代码示例,展示了Types.getBaseClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Types.getBaseClass()
方法的具体详情如下:
包路径:org.jvnet.tiger_types.Types
类名称:Types
方法名:getBaseClass
[英]Gets the parameterization of the given base type.
For example, given the following
interface Foo extends List> {}
interface Bar extends Foo {}
This method works like this:
getBaseClass( Bar, List ) = List
getBaseClass( Bar, Foo ) = Foo
getBaseClass( Foo, Collection ) = Collection>
getBaseClass( ArrayList, List ) = List
[中]获取给定基类型的参数化。
例如,假设
interface Foo extends List> {}
interface Bar extends Foo {}
此方法的工作原理如下:
getBaseClass( Bar, List ) = List
getBaseClass( Bar, Foo ) = Foo
getBaseClass( Foo, Collection ) = Collection>
getBaseClass( ArrayList, List ) = List
代码示例来源:origin: jenkinsci/jenkins
protected RunListener() {
Type type = Types.getBaseClass(getClass(), RunListener.class);
if (type instanceof ParameterizedType)
targetType = Types.erasure(Types.getTypeArgument(type,0));
else
throw new IllegalStateException(getClass()+" uses the raw type for extending RunListener");
}
代码示例来源:origin: jenkinsci/jenkins
private Class computeItemType() {
if(clazz.isArray()) {
return clazz.getComponentType();
}
if(Collection.class.isAssignableFrom(clazz)) {
Type col = Types.getBaseClass(type, Collection.class);
if (col instanceof ParameterizedType)
return Types.erasure(Types.getTypeArgument(col,0));
else
return Object.class;
}
return null;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* For which context type does this annotator work?
*/
public Class<?> type() {
Type type = Types.getBaseClass(getClass(), ConsoleAnnotatorFactory.class);
if (type instanceof ParameterizedType)
return Types.erasure(Types.getTypeArgument(type,0));
else
return Object.class;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Unlike {@link #clazz}, return the parameter type 'T', which determines
* the {@link DescriptorExtensionList} that this goes to.
*
* <p>
* In those situations where subtypes cannot provide the type parameter,
* this method can be overridden to provide it.
*/
public Class<T> getT() {
Type subTyping = Types.getBaseClass(getClass(), Descriptor.class);
if (!(subTyping instanceof ParameterizedType)) {
throw new IllegalStateException(getClass()+" doesn't extend Descriptor with a type parameter.");
}
return Types.erasure(Types.getTypeArgument(subTyping, 0));
}
代码示例来源:origin: jenkinsci/jenkins
Type bt = Types.getBaseClass(getClass(), Descriptor.class);
if (bt instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType) bt;
代码示例来源:origin: jenkinsci/jenkins
/**
* Returns true if this {@link JobProperty} type is applicable to the
* given job type.
*
* <p>
* The default implementation of this method checks if the given job type is assignable to {@code J} of
* {@link JobProperty}{@code <J>}, but subtypes can extend this to change this behavior.
*
* @return
* true to indicate applicable, in which case the property will be
* displayed in the configuration screen of this job.
*/
public boolean isApplicable(Class<? extends Job> jobType) {
Type parameterization = Types.getBaseClass(clazz, JobProperty.class);
if (parameterization instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType) parameterization;
Class applicable = Types.erasure(Types.getTypeArgument(pt, 0));
return applicable.isAssignableFrom(jobType);
} else {
throw new AssertionError(clazz+" doesn't properly parameterize JobProperty. The isApplicable() method must be overridden.");
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Given {@code c=MyList (extends ArrayList<Foo>), base=List}, compute the parameterization of 'base'
* that's assignable from 'c' (in this case {@code List<Foo>}), and return its n-th type parameter
* (n=0 would return {@code Foo}).
*
* <p>
* This method is useful for doing type arithmetic.
*
* @throws AssertionError
* if c' is not parameterized.
*/
public static <B> Class getTypeParameter(Class<? extends B> c, Class<B> base, int n) {
Type parameterization = Types.getBaseClass(c,base);
if (parameterization instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType) parameterization;
return Types.erasure(Types.getTypeArgument(pt,n));
} else {
throw new AssertionError(c+" doesn't properly parameterize "+base);
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Configured instances of {@link ToolInstallation}s.
*
* @return read-only list of installations;
* can be empty but never null.
*/
@SuppressWarnings("unchecked")
public T[] getInstallations() {
if (installations != null)
return installations.clone();
Type bt = Types.getBaseClass(getClass(), ToolDescriptor.class);
if (bt instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType) bt;
// this 't' is the closest approximation of T of Descriptor<T>.
Class t = Types.erasure(pt.getActualTypeArguments()[0]);
return (T[])Array.newInstance(t,0);
} else {
// can't infer the type. Fallback
return emptyArray_unsafeCast();
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Auto-discovers {@link OptionHandler}s and add them to the given command line parser.
*/
protected void registerOptionHandlers() {
try {
for (Class c : Index.list(OptionHandlerExtension.class, Jenkins.getActiveInstance().pluginManager.uberClassLoader,Class.class)) {
Type t = Types.getBaseClass(c, OptionHandler.class);
CmdLineParser.registerHandler(Types.erasure(Types.getTypeArgument(t,0)), c);
}
} catch (IOException e) {
throw new Error(e);
}
}
代码示例来源:origin: javaee/glassfish
final Type col = Types.getBaseClass(t, Collection.class);
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
protected RunListener() {
Type type = Types.getBaseClass(getClass(), RunListener.class);
if (type instanceof ParameterizedType)
targetType = Types.erasure(Types.getTypeArgument(type,0));
else
throw new IllegalStateException(getClass()+" uses the raw type for extending RunListener");
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
protected RunListener() {
Type type = Types.getBaseClass(getClass(), RunListener.class);
if (type instanceof ParameterizedType)
targetType = Types.erasure(Types.getTypeArgument(type,0));
else
throw new IllegalStateException(getClass()+" uses the raw type for extending RunListener");
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
protected RunListener() {
Type type = Types.getBaseClass(getClass(), RunListener.class);
if (type instanceof ParameterizedType)
targetType = Types.erasure(Types.getTypeArgument(type,0));
else
throw new IllegalStateException(getClass()+" uses the raw type for extending RunListener");
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
protected RunListener() {
Type type = Types.getBaseClass(getClass(), RunListener.class);
if (type instanceof ParameterizedType) {
targetType = Types.erasure(Types.getTypeArgument(type, 0));
} else {
throw new IllegalStateException(getClass() + " uses the raw type for extending RunListener");
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
/**
* For which context type does this annotator work?
*/
public Class type() {
Type type = Types.getBaseClass(getClass(), ConsoleAnnotator.class);
if (type instanceof ParameterizedType)
return Types.erasure(Types.getTypeArgument(type,0));
else
return Object.class;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* For which context type does this annotator work?
*/
public Class type() {
Type type = Types.getBaseClass(getClass(), ConsoleAnnotator.class);
if (type instanceof ParameterizedType)
return Types.erasure(Types.getTypeArgument(type,0));
else
return Object.class;
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
/**
* For which context type does this annotator work?
*/
public Class type() {
Type type = Types.getBaseClass(getClass(), ConsoleAnnotator.class);
if (type instanceof ParameterizedType)
return Types.erasure(Types.getTypeArgument(type,0));
else
return Object.class;
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
/**
* For which context type does this annotator work?
*/
public Class type() {
Type type = Types.getBaseClass(getClass(), ConsoleAnnotator.class);
if (type instanceof ParameterizedType) {
return Types.erasure(Types.getTypeArgument(type, 0));
} else {
return Object.class;
}
}
代码示例来源:origin: hudson/hudson-2.x
/**
* For which context type does this annotator work?
*/
public Class type() {
Type type = Types.getBaseClass(getClass(), ConsoleAnnotator.class);
if (type instanceof ParameterizedType)
return Types.erasure(Types.getTypeArgument(type,0));
else
return Object.class;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Auto-discovers {@link OptionHandler}s and add them to the given command line parser.
*/
protected void registerOptionHandlers() {
try {
for (Class c : Index.list(OptionHandlerExtension.class, Jenkins.getActiveInstance().pluginManager.uberClassLoader,Class.class)) {
Type t = Types.getBaseClass(c, OptionHandler.class);
CmdLineParser.registerHandler(Types.erasure(Types.getTypeArgument(t,0)), c);
}
} catch (IOException e) {
throw new Error(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!