Class JavaDelegatingResolveResult<ReferenceType extends EObject,T extends ReferenceType>
- java.lang.Object
-
- org.emftext.language.java.resolver.result.JavaDelegatingResolveResult<ReferenceType,T>
-
- Type Parameters:
ReferenceType- the type of the references that can be contained in the wrapped result.T- the type of the references that can be contained in this result.
- All Implemented Interfaces:
IJavaReferenceResolveResult<T>
public class JavaDelegatingResolveResult<ReferenceType extends EObject,T extends ReferenceType> extends Object implements IJavaReferenceResolveResult<T>
An implementation of the ResolveResult interface that delegates all method calls to another ResolveResult. Client may subclass this class to easily create custom ResolveResults.
-
-
Constructor Summary
Constructors Constructor Description JavaDelegatingResolveResult(IJavaReferenceResolveResult<ReferenceType> delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMapping(String identifier, T target)Adds a mapping from the given identifier to the given object.StringgetErrorMessage()Returns the error message that describes what went wrong while resolving a reference.Collection<IJavaReferenceMapping<T>>getMappings()Returns all mappings that were found while resolving an identifier.voidsetErrorMessage(String message)Sets the error message that describes what went wrong while resolving a reference.booleanwasResolved()Indicates the type of the result.booleanwasResolvedMultiple()Indicates the type of the result.booleanwasResolvedUniquely()Indicates the type of the result.
-
-
-
Constructor Detail
-
JavaDelegatingResolveResult
public JavaDelegatingResolveResult(IJavaReferenceResolveResult<ReferenceType> delegate)
-
-
Method Detail
-
getErrorMessage
public String getErrorMessage()
Description copied from interface:IJavaReferenceResolveResultReturns the error message that describes what went wrong while resolving a reference.- Specified by:
getErrorMessagein interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>- Returns:
- the error message.
-
getMappings
public Collection<IJavaReferenceMapping<T>> getMappings()
Description copied from interface:IJavaReferenceResolveResultReturns all mappings that were found while resolving an identifier.- Specified by:
getMappingsin interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>- Returns:
- the mappings.
-
wasResolved
public boolean wasResolved()
Description copied from interface:IJavaReferenceResolveResultIndicates 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:
wasResolvedin interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>- Returns:
- true if the reference was successfully resolved.
-
wasResolvedMultiple
public boolean wasResolvedMultiple()
Description copied from interface:IJavaReferenceResolveResultIndicates 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:
wasResolvedMultiplein interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>- Returns:
- true the reference was resolved to more than one target object.
-
wasResolvedUniquely
public boolean wasResolvedUniquely()
Description copied from interface:IJavaReferenceResolveResultIndicates 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:
wasResolvedUniquelyin 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:IJavaReferenceResolveResultSets 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:
setErrorMessagein interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>- Parameters:
message- the error that prevented resolving the reference.
-
addMapping
public void addMapping(String identifier, T target)
Description copied from interface:IJavaReferenceResolveResultAdds 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:
addMappingin interfaceIJavaReferenceResolveResult<ReferenceType extends EObject>- Parameters:
identifier- the given identifier.target- the resolved target object for the identifier.
-
-