[77] | 1 | package com.framsticks.params; |
---|
| 2 | |
---|
| 3 | |
---|
| 4 | |
---|
[84] | 5 | |
---|
[99] | 6 | import com.framsticks.params.types.EventParam; |
---|
[90] | 7 | import com.framsticks.params.types.ProcedureParam; |
---|
| 8 | |
---|
[77] | 9 | /** |
---|
| 10 | * @author Piotr Sniegowski |
---|
| 11 | */ |
---|
[100] | 12 | public abstract class ListAccess implements Access { |
---|
[77] | 13 | |
---|
[100] | 14 | final Access elementAccess; |
---|
[99] | 15 | final String containedTypeName; |
---|
[77] | 16 | |
---|
[99] | 17 | protected final ParamBuilder paramBuilder; |
---|
| 18 | |
---|
[100] | 19 | public ListAccess(Access elementAccess) { |
---|
[77] | 20 | this.elementAccess = elementAccess; |
---|
[105] | 21 | this.containedTypeName = elementAccess.getTypeId(); |
---|
[99] | 22 | paramBuilder = elementAccess.buildParam(new ParamBuilder()); |
---|
[77] | 23 | } |
---|
| 24 | |
---|
[90] | 25 | // @Override |
---|
| 26 | // public Param getGroupMember(int gi, int n) { |
---|
| 27 | // return null; |
---|
| 28 | // } |
---|
[77] | 29 | |
---|
| 30 | |
---|
[100] | 31 | public Access getElementAccess() { |
---|
[77] | 32 | return elementAccess; |
---|
| 33 | } |
---|
| 34 | |
---|
[99] | 35 | /** |
---|
| 36 | * @return the containedTypeName |
---|
| 37 | */ |
---|
| 38 | public String getContainedTypeName() { |
---|
| 39 | return containedTypeName; |
---|
| 40 | } |
---|
[77] | 41 | |
---|
[84] | 42 | @Override |
---|
| 43 | public final FramsClass getFramsClass() { |
---|
| 44 | return elementAccess.getFramsClass(); |
---|
| 45 | } |
---|
[77] | 46 | |
---|
[87] | 47 | @Override |
---|
[96] | 48 | public void tryAutoAppend(Object object) { |
---|
[102] | 49 | throw new InvalidOperationException().msg("It could actually be used also, the Access.select could be used to check whether type is correct"); |
---|
[87] | 50 | } |
---|
| 51 | |
---|
[90] | 52 | @Override |
---|
[105] | 53 | public Object call(String id, Object... arguments) { |
---|
[99] | 54 | throw new InvalidOperationException().msg("list access does not support calling methods").arg("id", id).arg("access", this); |
---|
[90] | 55 | } |
---|
| 56 | |
---|
| 57 | @Override |
---|
[105] | 58 | public Object call(ProcedureParam param, Object... arguments) { |
---|
[99] | 59 | throw new InvalidOperationException().msg("list access does not support calling methods").arg("param", param).arg("access", this); |
---|
[90] | 60 | } |
---|
| 61 | |
---|
[99] | 62 | @Override |
---|
| 63 | public void reg(EventParam param, EventListener<?> listener) { |
---|
| 64 | throw new InvalidOperationException().msg("list access does not support registering events").arg("param", param).arg("access", this); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | @Override |
---|
| 68 | public void regRemove(EventParam param, EventListener<?> listener) { |
---|
| 69 | throw new InvalidOperationException().msg("list access does not support registering events").arg("param", param).arg("access", this); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | @Override |
---|
| 74 | public String toString() { |
---|
| 75 | StringBuilder b = new StringBuilder(); |
---|
| 76 | b.append("list of ").append(containedTypeName); |
---|
| 77 | if (getSelected() != null) { |
---|
| 78 | b.append("[").append(getParamCount()).append("]"); |
---|
| 79 | } |
---|
| 80 | return b.toString(); |
---|
| 81 | } |
---|
[100] | 82 | |
---|
| 83 | public CompositeParam prepareParamFor(String id) { |
---|
| 84 | return paramBuilder.id(id).finish(CompositeParam.class); |
---|
| 85 | } |
---|
[87] | 86 | }; |
---|