Package ai.timefold.jpyinterpreter.types
Class PythonLikeType
java.lang.Object
ai.timefold.jpyinterpreter.types.PythonLikeType
- All Implemented Interfaces:
PythonLikeObject,PythonLikeFunction
- Direct Known Subclasses:
CPythonType,PythonKnownFunctionType,PythonLikeGenericType
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPythonLikeType(String typeName, Class<? extends PythonLikeObject> javaClass) PythonLikeType(String typeName, Class<? extends PythonLikeObject> javaClass, Class<?> javaObjectWrapperType) PythonLikeType(String typeName, Class<? extends PythonLikeObject> javaClass, Consumer<PythonLikeType> initializer) PythonLikeType(String typeName, Class<? extends PythonLikeObject> javaClass, List<PythonLikeType> parents) PythonLikeType(String typeName, String javaTypeInternalName, List<PythonLikeType> parents) -
Method Summary
Modifier and TypeMethodDescription$call(List<PythonLikeObject> positionalArguments, Map<PythonString, PythonLikeObject> namedArguments, PythonLikeObject callerInstance) Calls the function with positional arguments and named arguments.void$deleteAttribute(String attributeName) Delete an attribute by name.$getAttributeOrNull(String attributeName) Gets an attribute by name.Return a generic version ofPythonLikeObject.$getType().$getType()Returns the type describing the object$method$__getattribute__(PythonString pythonName) void$setAttribute(String attributeName, PythonLikeObject value) Sets an attribute by name.voidaddBinaryMethod(PythonBinaryOperator operator, PythonFunctionSignature method) voidaddBinaryMethod(PythonBinaryOperator operator, Method method) voidaddConstructor(PythonFunctionSignature constructor) voidaddInstanceField(FieldDescriptor fieldDescriptor) voidaddLeftBinaryMethod(PythonBinaryOperator operator, PythonFunctionSignature method) voidaddLeftBinaryMethod(PythonBinaryOperator operator, Method method) voidaddMethod(String methodName, PythonFunctionSignature method) voidvoidaddRightBinaryMethod(PythonBinaryOperator operator, PythonFunctionSignature method) voidaddRightBinaryMethod(PythonBinaryOperator operator, Method method) voidaddTernaryMethod(PythonTernaryOperator operator, PythonFunctionSignature method) voidaddTernaryMethod(PythonTernaryOperator operator, Method method) voidaddUnaryMethod(PythonUnaryOperator operator, PythonFunctionSignature method) voidaddUnaryMethod(PythonUnaryOperator operator, Method method) voidclearMethod(String methodName) booleangetDefiningTypeOrNull(String attributeName) intgetDepth()getInstanceFieldDescriptor(String fieldName) Class<?>Return the Java class corresponding to this type, if it exists.Class<?>getJavaClassOrDefault(Class<?> defaultValue) Return the Java class corresponding to this type, if it exists.Class<?>getMethodKind(String methodName) getMethodType(String methodName) static PythonLikeTypegetTypeForNewClass(String typeName, String internalName) inthashCode()voidinitializeNewType(List<PythonLikeType> superClassTypes) booleanisInstance(PythonLikeObject object) booleanisSubclassOf(PythonLikeType type) loadMethod(String methodName) static PythonLikeTypestatic PythonLikeTypevoidsetConstructor(PythonLikeFunction constructor) toString()unifyWith(PythonLikeType other) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface ai.timefold.jpyinterpreter.PythonLikeObject
$getAttributeOrError, $method$__delattr__, $method$__eq__, $method$__format__, $method$__format__, $method$__hash__, $method$__ne__, $method$__repr__, $method$__setattr__
-
Field Details
-
__dir__
-
MRO
-
-
Constructor Details
-
PythonLikeType
-
PythonLikeType
public PythonLikeType(String typeName, Class<? extends PythonLikeObject> javaClass, Class<?> javaObjectWrapperType) -
PythonLikeType
public PythonLikeType(String typeName, Class<? extends PythonLikeObject> javaClass, List<PythonLikeType> parents) -
PythonLikeType
-
PythonLikeType
public PythonLikeType(String typeName, Class<? extends PythonLikeObject> javaClass, Consumer<PythonLikeType> initializer)
-
-
Method Details
-
getTypeForNewClass
-
initializeNewType
-
isInstance
-
registerBaseType
-
getJavaObjectWrapperType
-
registerTypeType
-
$method$__getattribute__
- Specified by:
$method$__getattribute__in interfacePythonLikeObject
-
addMethod
-
addUnaryMethod
-
addBinaryMethod
-
addLeftBinaryMethod
-
addRightBinaryMethod
-
addTernaryMethod
-
addUnaryMethod
-
addBinaryMethod
-
addLeftBinaryMethod
-
addRightBinaryMethod
-
addTernaryMethod
-
clearMethod
-
addMethod
-
getKnownMethodsDefinedByClass
-
getKnownMethods
-
setConstructor
-
addConstructor
-
getMethodType
-
getMethodKind
-
getConstructorType
-
getInstanceFieldDescriptor
-
addInstanceField
-
unifyWith
-
isSubclassOf
-
getDepth
public int getDepth() -
$call
public PythonLikeObject $call(List<PythonLikeObject> positionalArguments, Map<PythonString, PythonLikeObject> namedArguments, PythonLikeObject callerInstance) Description copied from interface:PythonLikeFunctionCalls the function with positional arguments and named arguments.- Specified by:
$callin interfacePythonLikeFunction- Parameters:
positionalArguments- Positional argumentsnamedArguments- Named argumentscallerInstance- The first argument passed to the caller, if any; null otherwise (used for super)- Returns:
- The function result
-
loadMethod
-
getDefiningTypeOrNull
-
$getAttributeOrNull
Description copied from interface:PythonLikeObjectGets an attribute by name.- Specified by:
$getAttributeOrNullin interfacePythonLikeFunction- Specified by:
$getAttributeOrNullin interfacePythonLikeObject- Parameters:
attributeName- Name of the attribute to get- Returns:
- The attribute of the object that corresponds with attributeName
-
$setAttribute
Description copied from interface:PythonLikeObjectSets an attribute by name.- Specified by:
$setAttributein interfacePythonLikeFunction- Specified by:
$setAttributein interfacePythonLikeObject- Parameters:
attributeName- Name of the attribute to setvalue- Value to set the attribute to
-
$deleteAttribute
Description copied from interface:PythonLikeObjectDelete an attribute by name.- Specified by:
$deleteAttributein interfacePythonLikeFunction- Specified by:
$deleteAttributein interfacePythonLikeObject- Parameters:
attributeName- Name of the attribute to delete
-
$getType
Description copied from interface:PythonLikeObjectReturns the type describing the object- Specified by:
$getTypein interfacePythonLikeFunction- Specified by:
$getTypein interfacePythonLikeObject- Returns:
- the type describing the object
-
$getGenericType
Description copied from interface:PythonLikeObjectReturn a generic version ofPythonLikeObject.$getType(). This is used in bytecode generation and not at runtime. For example, for a list of integers, this return list[int], while getType returns list. Both methods are needed so type([1,2,3]) is type(['a', 'b', 'c']) return True.- Specified by:
$getGenericTypein interfacePythonLikeObject- Returns:
- the generic version of this object's type. Must not be used in identity checks.
-
getTypeName
-
getJavaTypeInternalName
-
getJavaTypeDescriptor
-
getJavaClass
Return the Java class corresponding to this type, if it exists. ThrowsClassNotFoundExceptionotherwise.- Throws:
ClassNotFoundException
-
getJavaClassOrDefault
Return the Java class corresponding to this type, if it exists. ReturnsdefaultValueotherwise.- Parameters:
defaultValue- the value to return
-
getParentList
-
$method$__str__
- Specified by:
$method$__str__in interfacePythonLikeObject
-
toString
-
equals
-
hashCode
public int hashCode()
-