mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Replacement for asSubclass()
This commit is contained in:
parent
0ff60a2809
commit
56ac30b3b1
@ -229,7 +229,7 @@ class ReplacementForClass<T> {
|
|||||||
* @return true, if type {@code cls} can be assigned to objects of this class
|
* @return true, if type {@code cls} can be assigned to objects of this class
|
||||||
*/
|
*/
|
||||||
@WasmTextCode( "unreachable" ) // TODO
|
@WasmTextCode( "unreachable" ) // TODO
|
||||||
public native boolean isAssignableFrom( Class<?> cls );
|
public native boolean isAssignableFrom( ReplacementForClass<?> cls );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replacement of the Java method isInterface()
|
* Replacement of the Java method isInterface()
|
||||||
@ -501,4 +501,19 @@ class ReplacementForClass<T> {
|
|||||||
throw new ClassCastException("Cannot cast " + obj.getClass().getName() + " to " + getName());
|
throw new ClassCastException("Cannot cast " + obj.getClass().getName() + " to " + getName());
|
||||||
return (T) obj;
|
return (T) obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replacement of the Java method asSubclass(Class)
|
||||||
|
*
|
||||||
|
* @param clazz
|
||||||
|
* the class of the type to cast this class object to
|
||||||
|
* @return this
|
||||||
|
*/
|
||||||
|
@SuppressWarnings( "unchecked" )
|
||||||
|
public <U> ReplacementForClass<? extends U> asSubclass( ReplacementForClass<U> clazz ) {
|
||||||
|
if( clazz.isAssignableFrom( this ) )
|
||||||
|
return (ReplacementForClass<? extends U>)this;
|
||||||
|
else
|
||||||
|
throw new ClassCastException( this.toString() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user