| 1 | /*
|
| 2 | * JavaTypeSubstitutedFormalParameterModel.java
|
| 3 | *
|
| 4 | * Created on May 3, 2007, 2:56 PM
|
| 5 | *
|
| 6 | * To change this template, choose Tools | Template Manager
|
| 7 | * and open the template in the editor.
|
| 8 | */
|
| 9 |
|
| 10 | package ua.gradsoft.javachecker.models;
|
| 11 |
|
| 12 | import java.util.Map;
|
| 13 | import ua.gradsoft.javachecker.EntityNotFoundException;
|
| 14 | import ua.gradsoft.javachecker.util.ImmutableMappedMap;
|
| 15 | import ua.gradsoft.javachecker.util.Function;
|
| 16 | import ua.gradsoft.termware.TermWareException;
|
| 17 |
|
| 18 | /**
|
| 19 | *formalParameter model after applying type substitution
|
| 20 | * @author rssh
|
| 21 | */
|
| 22 | public class JavaTypeSubstitutedFormalParameterModel extends JavaFormalParameterModel
|
| 23 | {
|
| 24 |
|
| 25 | /** Creates a new instance of JavaTypeSubstitutedFormalParameterModel */
|
| 26 | public JavaTypeSubstitutedFormalParameterModel(JavaFormalParameterModel origin,JavaTypeArgumentBoundTopLevelBlockOwnerModel blockOwner) {
|
| 27 | origin_=origin;
|
| 28 | blockOwner_=blockOwner;
|
| 29 | }
|
| 30 |
|
| 31 | public JavaModifiersModel getModifiers()
|
| 32 | { return origin_.getModifiers(); }
|
| 33 |
|
| 34 |
|
| 35 | public String getName()
|
| 36 | { return origin_.getName(); }
|
| 37 |
|
| 38 | public JavaTypeModel getType() throws TermWareException, EntityNotFoundException
|
| 39 | { return blockOwner_.getTypeArgumentBoundTypeModel().getSubstitution().substitute(origin_.getType()); }
|
| 40 |
|
| 41 | public JavaTopLevelBlockOwnerModel getTopLevelBlockOwner()
|
| 42 | { return blockOwner_; }
|
| 43 |
|
| 44 |
|
| 45 | public Map<String,JavaAnnotationInstanceModel> getAnnotationsMap()
|
| 46 | {
|
| 47 | return new ImmutableMappedMap(origin_.getAnnotationsMap(),
|
| 48 | new Function<JavaAnnotationInstanceModel,JavaAnnotationInstanceModel>(){
|
| 49 | public JavaAnnotationInstanceModel function(JavaAnnotationInstanceModel x)
|
| 50 | {
|
| 51 | return new JavaDelegatedAnnotationInstanceModel(x,JavaTypeSubstitutedFormalParameterModel.this);
|
| 52 | }
|
| 53 | }
|
| 54 | );
|
| 55 | }
|
| 56 |
|
| 57 |
|
| 58 | /**
|
| 59 | *@return index of this formal parameters in call, started from 0
|
| 60 | */
|
| 61 | public int getIndex()
|
| 62 | { return origin_.getIndex(); }
|
| 63 |
|
| 64 | public boolean isConstant() throws TermWareException, EntityNotFoundException
|
| 65 | {
|
| 66 | return origin_.isConstant();
|
| 67 | }
|
| 68 |
|
| 69 |
|
| 70 | private JavaFormalParameterModel origin_;
|
| 71 | private JavaTypeArgumentBoundTopLevelBlockOwnerModel blockOwner_;
|
| 72 | }
|