Rework TypedRowInvocationHandler invocation path
[ovsdb.git] / library / impl / src / main / java / org / opendaylight / ovsdb / lib / schema / typed / GetColumn.java
1 /*
2  * Copyright © 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.ovsdb.lib.schema.typed;
9
10 import java.lang.reflect.Method;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.ovsdb.lib.notation.Column;
13 import org.opendaylight.ovsdb.lib.notation.Row;
14 import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
15 import org.opendaylight.ovsdb.lib.schema.GenericTableSchema;
16
17 final class GetColumn<T> extends MethodDispatch.StrictColumnPrototype<T> {
18     private static final class Invoker<T> extends MethodDispatch.ColumnInvoker<T> {
19         Invoker(final @NonNull GenericTableSchema tableSchema,
20                 final @NonNull ColumnSchema<GenericTableSchema, T> columnSchema) {
21             super(tableSchema, columnSchema);
22         }
23
24         @Override
25         Object invokeMethod(final Object proxy, final Object[] args) {
26             return new Column<>(columnSchema(), null);
27         }
28
29         @Override
30         Object invokeRowMethod(final Row<GenericTableSchema> row, final Object proxy, final Object[] args) {
31             return row.getColumn(columnSchema());
32         }
33     }
34
35     GetColumn(final Method method, final String tableName, final String columnName) {
36         super(method, tableName, columnName);
37     }
38
39     @Override
40     Invoker<T> bindToImpl(final GenericTableSchema tableSchema,
41             final ColumnSchema<GenericTableSchema, T> columnSchema) {
42         return new Invoker<>(tableSchema, columnSchema);
43     }
44 }