Class JavaReferenceResolveResult<ReferenceType extends EObject>
- java.lang.Object
-
- org.emftext.language.java.resolver.result.JavaReferenceResolveResult<ReferenceType>
-
- Type Parameters:
ReferenceType
- the type of the references that can be contained in this result.
- All Implemented Interfaces:
IJavaReferenceResolveResult<ReferenceType>
public class JavaReferenceResolveResult<ReferenceType extends EObject> extends Object implements IJavaReferenceResolveResult<ReferenceType>
A basic implementation of the org.emftext.language.java.resource.java.IJavaReferenceResolveResult interface that collects mappings in a list.
-
-
Constructor Summary
Constructors Constructor Description JavaReferenceResolveResult()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMapping(String identifier, ReferenceType target)
Adds a mapping from the given identifier to the given object.String
getErrorMessage()
Returns the error message that describes what went wrong while resolving a reference.Collection<IJavaReferenceMapping<ReferenceType>>
getMappings()
Returns all mappings that were found while resolving an identifier.void
setErrorMessage(String message)
Sets the error message that describes what went wrong while resolving a reference.boolean
wasResolved()
Indicates the type of the result.boolean
wasResolvedMultiple()
Indicates the type of the result.boolean
wasResolvedUniquely()
Indicates the type of the result.
-
-
-
Method Detail
-
getErrorMessage
public String getErrorMessage()
Description copied from interface:IJavaReferenceResolveResult
Returns the error message that describes what went wrong while resolving a reference.- Specified by:
getErrorMessage
in interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>
- Returns:
- the error message.
-
getMappings
public Collection<IJavaReferenceMapping<ReferenceType>> getMappings()
Description copied from interface:IJavaReferenceResolveResult
Returns all mappings that were found while resolving an identifier.- Specified by:
getMappings
in interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>
- Returns:
- the mappings.
-
wasResolved
public boolean wasResolved()
Description copied from interface:IJavaReferenceResolveResult
Indicates the type of the result. Depending on the type of the result, different information is available (e.g., the error message is only set if the resolve operation failed).- Specified by:
wasResolved
in interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>
- Returns:
- true if the reference was successfully resolved.
-
wasResolvedMultiple
public boolean wasResolvedMultiple()
Description copied from interface:IJavaReferenceResolveResult
Indicates the type of the result. Depending on the type of the result, different information is available (e.g., the multiple mappings are only set if the resolve operation returned multiple result).- Specified by:
wasResolvedMultiple
in interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>
- Returns:
- true the reference was resolved to more than one target object.
-
wasResolvedUniquely
public boolean wasResolvedUniquely()
Description copied from interface:IJavaReferenceResolveResult
Indicates the type of the result. Depending on the type of the result, different information is available (e.g., the unique mapping is only set if the resolve operation returned a unique result).- Specified by:
wasResolvedUniquely
in interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>
- Returns:
- true if the reference was resolved to exactly one target object.
-
setErrorMessage
public void setErrorMessage(String message)
Description copied from interface:IJavaReferenceResolveResult
Sets the error message that describes what went wrong while resolving a reference. If a mapping for the reference was already found (i.e., addMapping() was called before), the call to this method is ignored. If addMapping() is called afterwards, the error message is also discarded.- Specified by:
setErrorMessage
in interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>
- Parameters:
message
- the error that prevented resolving the reference.
-
addMapping
public void addMapping(String identifier, ReferenceType target)
Description copied from interface:IJavaReferenceResolveResult
Adds a mapping from the given identifier to the given object. Adding such a mapping means that the identifier was resolved to reference the target object. Previous errors as well as future ones will be discarded. Once a mapping is found, resolve errors have no meaning anymore. The target must not be null and implementations of this method can throw an IllegalArgumentException if this rule is violated.- Specified by:
addMapping
in interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>
- Parameters:
identifier
- the given identifier.target
- the resolved target object for the identifier.
-
-