Skip to content

Commit

Permalink
Add common interface to function and procedures
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Apr 23, 2018
1 parent 0b01554 commit 71a8c9a
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 3 deletions.
Expand Up @@ -33,7 +33,7 @@
* This describes the signature of a procedure, made up of its namespace, name, and input/output description.
* Procedure uniqueness is currently *only* on the namespace/name level - no procedure overloading allowed (yet).
*/
public class ProcedureSignature
public class ProcedureSignature implements Signature
{
public static final List<FieldSignature> VOID = unmodifiableList( new ArrayList<>() );

Expand Down Expand Up @@ -65,6 +65,7 @@ public ProcedureSignature( QualifiedName name,
this.warning = warning;
}

@Override
public QualifiedName name()
{
return name;
Expand All @@ -75,16 +76,19 @@ public Mode mode()
return mode;
}

@Override
public Optional<String> deprecated()
{
return Optional.ofNullable( deprecated );
}

@Override
public String[] allowed()
{
return allowed;
}

@Override
public List<FieldSignature> inputSignature()
{
return inputSignature;
Expand All @@ -100,6 +104,7 @@ public boolean isVoid()
return outputSignature == VOID;
}

@Override
public Optional<String> description()
{
return Optional.ofNullable( description );
Expand Down
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2002-2018 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.internal.kernel.api.procs;

import java.util.List;
import java.util.Optional;

public interface Signature
{
QualifiedName name();

Optional<String> deprecated();

List<FieldSignature> inputSignature();

Optional<String> description();

String[] allowed();
}
Expand Up @@ -34,7 +34,7 @@
* This describes the signature of a function, made up of its namespace, name, and input/output description.
* Function uniqueness is currently *only* on the namespace/name level - no function overloading allowed (yet).
*/
public final class UserFunctionSignature
public final class UserFunctionSignature implements Signature
{
private final QualifiedName name;
private final List<FieldSignature> inputSignature;
Expand All @@ -58,16 +58,19 @@ public UserFunctionSignature( QualifiedName name,
this.allowed = allowed;
}

@Override
public QualifiedName name()
{
return name;
}

@Override
public Optional<String> deprecated()
{
return Optional.ofNullable( deprecated );
}

@Override
public List<FieldSignature> inputSignature()
{
return inputSignature;
Expand All @@ -78,11 +81,13 @@ public Neo4jTypes.AnyType outputType()
return type;
}

@Override
public Optional<String> description()
{
return Optional.ofNullable( description );
}

@Override
public String[] allowed()
{
return allowed;
Expand Down
Expand Up @@ -26,14 +26,15 @@
import java.util.Map;

import org.neo4j.internal.kernel.api.procs.QualifiedName;
import org.neo4j.internal.kernel.api.procs.Signature;

/**
* Simple in memory store for procedures.
*
* Should only be accessed from a single thread
* @param <T> the type to be stored
*/
class ProcedureHolder<T>
class ProcedureHolder<T extends Signature>
{
private final Map<QualifiedName,Integer> nameToId = new HashMap<>();
private final ArrayList<T> store = new ArrayList<>();
Expand Down

0 comments on commit 71a8c9a

Please sign in to comment.