Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 65df3641fc5e9999490b73c58680b3973ba2a441 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 * Copyright (c) 2013 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.net4j.internal.db.ddl;

import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBIndexField;
import org.eclipse.net4j.db.ddl.IDBSchemaElement;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.db.ddl.SchemaElementNotFoundException;
import org.eclipse.net4j.spi.db.ddl.InternalDBIndex;

/**
 * @author Eike Stepper
 */
public final class DelegatingDBIndex extends DelegatingDBSchemaElement implements InternalDBIndex
{
  DelegatingDBIndex(InternalDBIndex delegate)
  {
    super(delegate);
  }

  @Override
  public InternalDBIndex getDelegate()
  {
    return (InternalDBIndex)super.getDelegate();
  }

  @Override
  public void setDelegate(IDBSchemaElement delegate)
  {
    IDBIndexField[] wrapperIndexFields = getIndexFields();

    IDBIndex delegateIndex = (IDBIndex)delegate;
    super.setDelegate(delegateIndex);

    for (IDBIndexField wrapperIndexField : wrapperIndexFields)
    {
      IDBIndexField delegateIndexField = delegateIndex.getIndexField(wrapperIndexField.getName());
      ((DelegatingDBSchemaElement)wrapperIndexField).setDelegate(delegateIndexField);
    }
  }

  public IDBIndex getWrapper()
  {
    return this;
  }

  @Override
  public IDBTable getParent()
  {
    return wrap(getDelegate().getParent());
  }

  public IDBTable getTable()
  {
    return wrap(getDelegate().getTable());
  }

  public Type getType()
  {
    return getDelegate().getType();
  }

  public void setType(Type type)
  {
    getDelegate().setType(type);
  }

  public void removeIndexField(IDBIndexField indexFieldToRemove)
  {
    getDelegate().removeIndexField(unwrap(indexFieldToRemove));
  }

  public boolean isOptional()
  {
    return getDelegate().isOptional();
  }

  public void setOptional(boolean optional)
  {
    getDelegate().setOptional(optional);
  }

  @Deprecated
  public int getPosition()
  {
    return getDelegate().getPosition();
  }

  public IDBIndexField addIndexField(IDBField field)
  {
    return wrap(getDelegate().addIndexField(unwrap(field)));
  }

  public IDBIndexField addIndexField(String name) throws SchemaElementNotFoundException
  {
    return wrap(getDelegate().addIndexField(name));
  }

  public IDBIndexField getIndexFieldSafe(String name) throws SchemaElementNotFoundException
  {
    return wrap(getDelegate().getIndexFieldSafe(name));
  }

  public IDBIndexField getIndexField(String name)
  {
    return wrap(getDelegate().getIndexField(name));
  }

  public IDBIndexField getIndexField(int position)
  {
    return wrap(getDelegate().getIndexField(position));
  }

  public IDBField getFieldSafe(String name) throws SchemaElementNotFoundException
  {
    return wrap(getDelegate().getFieldSafe(name));
  }

  public IDBField getField(String name)
  {
    return wrap(getDelegate().getField(name));
  }

  public IDBField getField(int position)
  {
    return wrap(getDelegate().getField(position));
  }

  public int getFieldCount()
  {
    return getDelegate().getFieldCount();
  }

  public IDBIndexField[] getIndexFields()
  {
    return wrap(getDelegate().getIndexFields(), IDBIndexField.class);
  }

  public IDBField[] getFields()
  {
    return wrap(getDelegate().getFields(), IDBField.class);
  }
}

Back to the top