Creates and returns a method or constructor in this type with the given contents.
Optionally, the new element can be positioned before the specified sibling. If no sibling is specified, the element will be appended to this type.
It is possible that a method with the same signature already exists in this type. The value of the force
parameter affects the resolution of such a conflict:
-
true
- in this case the method is created with the new contents -
false
- in this case a JavaModelException
is thrown
@param contents the given contents
@param sibling the given sibling
@param force a flag in case the same name already exists in this type
@param monitor the given progress monitor
@exception JavaModelException if the element could not be created. Reasons include:
- This Java element does not exist (ELEMENT_DOES_NOT_EXIST)
- A
CoreException
occurred while updating an underlying resource - The specified sibling is not a child of this type (INVALID_SIBLING)
- The contents could not be recognized as a method or constructor declaration (INVALID_CONTENTS)
- This type is read-only (binary) (READ_ONLY)
- There was a naming collision with an existing method (NAME_COLLISION)
@return a method or constructor in this type with the given contents